Permalink
Browse files

test succ with the websocket module

  • Loading branch information...
1 parent 7519a6d commit 4be6a0efaf3654af799823a0b33297c6821da6b1 @yaoweibin committed Oct 18, 2011
View
12 config_without_ssl
@@ -2,11 +2,13 @@ ngx_feature="nginx_tcp_module"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
-ngx_feature_path="$ngx_addon_dir/modules $ngx_addon_dir"
+ngx_feature_path="$ngx_addon_dir/modules $ngx_addon_dir/parsers $ngx_addon_dir"
ngx_feature_deps="$ngx_addon_dir/ngx_tcp.h $ngx_addon_dir/ngx_tcp_session.h $ngx_addon_dir/ngx_tcp_upstream.h $ngx_addon_dir/ngx_tcp_upstream_check.h $ngx_addon_dir/ngx_tcp_upstream_round_robin.h"
-ngx_tcp_src="$ngx_addon_dir/ngx_tcp.c $ngx_addon_dir/ngx_tcp_core_module.c $ngx_addon_dir/ngx_tcp_session.c $ngx_addon_dir/ngx_tcp_access.c $ngx_addon_dir/ngx_tcp_log.c $ngx_addon_dir/ngx_tcp_upstream.c $ngx_addon_dir/ngx_tcp_upstream_round_robin.c $ngx_addon_dir/modules/ngx_tcp_generic_proxy_module.c $ngx_addon_dir/modules/ngx_tcp_websocket_proxy_module.c $ngx_addon_dir/modules/ngx_tcp_upstream_ip_hash_module.c $ngx_addon_dir/modules/ngx_tcp_upstream_busyness_module.c $ngx_addon_dir/ngx_tcp_upstream_check.c $ngx_addon_dir/http_response_parse.c $ngx_addon_dir/smtp_response_parse.c"
+ngx_tcp_src="$ngx_addon_dir/ngx_tcp.c $ngx_addon_dir/ngx_tcp_core_module.c $ngx_addon_dir/ngx_tcp_session.c $ngx_addon_dir/ngx_tcp_access.c $ngx_addon_dir/ngx_tcp_log.c $ngx_addon_dir/ngx_tcp_upstream.c $ngx_addon_dir/ngx_tcp_upstream_round_robin.c $ngx_addon_dir/modules/ngx_tcp_generic_proxy_module.c $ngx_addon_dir/modules/ngx_tcp_websocket_proxy_module.c $ngx_addon_dir/modules/ngx_tcp_upstream_ip_hash_module.c $ngx_addon_dir/modules/ngx_tcp_upstream_busyness_module.c $ngx_addon_dir/ngx_tcp_upstream_check.c "
ngx_tcp_ssl_deps="$ngx_addon_dir/modules/ngx_tcp_ssl_module.h"
ngx_tcp_ssl_src="$ngx_addon_dir/modules/ngx_tcp_ssl_module.c"
+ngx_tcp_parser_deps="$ngx_addon_dir/parsers/parser.h $ngx_addon_dir/parsers/http_request_parser.h $ngx_addon_dir/parsers/http_response_parser.h $ngx_addon_dir/parsers/smtp_response_parser.h"
+ngx_tcp_parser_src="$ngx_addon_dir/parsers/http_request_parser.c $ngx_addon_dir/parsers/http_response_parser.c $ngx_addon_dir/parsers/smtp_response_parser.c"
ngx_feature_test="int a;"
. auto/feature
@@ -15,13 +17,13 @@ if [ $ngx_found = yes ]; then
ngx_addon_name=ngx_tcp_module
TCP_CORE_MODULES="ngx_tcp_module ngx_tcp_core_module ngx_tcp_upstream_module"
- TCP_MODULES="ngx_tcp_proxy_module ngx_tcp_upstream_ip_hash_module"
TCP_MODULES="ngx_tcp_proxy_module ngx_tcp_websocket_module ngx_tcp_upstream_ip_hash_module ngx_tcp_upstream_busyness_module"
- NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_feature_deps"
- NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_tcp_src"
+ NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_feature_deps $ngx_tcp_parser_deps"
+ NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_tcp_src $ngx_tcp_parser_src"
#have=NGX_TCP_SSL . auto/have
+ #USE_OPENSSL=YES
#TCP_MODULES="$TCP_MODULES ngx_tcp_ssl_module"
#NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_tcp_ssl_deps"
#NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_tcp_ssl_src"
View
3 modules/ngx_tcp_generic_proxy_module.c
@@ -27,6 +27,7 @@ typedef struct ngx_tcp_proxy_conf_s {
} ngx_tcp_proxy_conf_t;
+static void ngx_tcp_proxy_init_session(ngx_connection_t *c, ngx_tcp_session_t *s);
static void ngx_tcp_proxy_init(ngx_connection_t *c, ngx_tcp_session_t *s);
static void ngx_tcp_upstream_proxy_generic_handler(ngx_tcp_session_t *s,
ngx_tcp_upstream_t *u);
@@ -120,7 +121,7 @@ ngx_module_t ngx_tcp_proxy_module = {
};
-void
+static void
ngx_tcp_proxy_init_session(ngx_connection_t *c, ngx_tcp_session_t *s)
{
ngx_tcp_proxy_conf_t *pcf;
View
427 modules/ngx_tcp_websocket_proxy_module.c
@@ -8,10 +8,13 @@
#define _GNU_SOURCE
#include <fcntl.h>
+#include <http_request_parser.h>
typedef struct ngx_tcp_websocket_s {
ngx_peer_connection_t *upstream;
ngx_buf_t *buffer;
+
+ http_request_parser *parser;
} ngx_tcp_websocket_ctx_t;
@@ -27,13 +30,29 @@ typedef struct ngx_tcp_websocket_conf_s {
} ngx_tcp_websocket_conf_t;
+static void ngx_tcp_websocket_init_session(ngx_connection_t *c, ngx_tcp_session_t *s);
static void ngx_tcp_websocket_init_upstream(ngx_connection_t *c, ngx_tcp_session_t *s);
static void ngx_tcp_upstream_websocket_proxy_init_handler(ngx_tcp_session_t *s,
ngx_tcp_upstream_t *u);
static char *ngx_tcp_websocket_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static void ngx_tcp_websocket_dummy_read_handler(ngx_event_t *ev);
static void ngx_tcp_websocket_dummy_write_handler(ngx_event_t *ev);
static void ngx_tcp_websocket_start_handler(ngx_event_t *ev);
+static void websocket_http_request_parser_init(http_request_parser *hp, void *data);
+
+static void request_method(void *data, const signed char *at, size_t length);
+static void request_uri(void *data, const signed char *at, size_t length);
+static void fragment(void *data, const signed char *at, size_t length);
+static void request_path(void *data, const signed char *at, size_t length);
+static void query_string(void *data, const signed char *at, size_t length);
+static void http_version(void *data, const signed char *at, size_t length);
+static void header_done(void *data, const signed char *at, size_t length);
+static void http_field(void *data, const signed char *field, size_t flen,
+ const signed char *value, size_t vlen);
+
+static void ngx_tcp_websocket_recv_handler(ngx_event_t *ev);
+static ngx_int_t websocket_http_request_parser_execute(http_request_parser *hp);
+
static void ngx_tcp_websocket_proxy_handler(ngx_event_t *ev);
static void *ngx_tcp_websocket_create_conf(ngx_conf_t *cf);
static char *ngx_tcp_websocket_merge_conf(ngx_conf_t *cf, void *parent,
@@ -43,7 +62,7 @@ static ngx_tcp_protocol_t ngx_tcp_websocket_protocol = {
ngx_string("tcp_websocket"),
{ 80, 443, 0, 0 },
NGX_TCP_WEBSOCKET_PROTOCOL,
- ngx_tcp_proxy_init_session,
+ ngx_tcp_websocket_init_session,
NULL,
NULL,
NULL,
@@ -54,40 +73,40 @@ static ngx_tcp_protocol_t ngx_tcp_websocket_protocol = {
static ngx_command_t ngx_tcp_websocket_commands[] = {
- { ngx_string("websocket_pass"),
- NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_tcp_websocket_pass,
- NGX_TCP_SRV_CONF_OFFSET,
- 0,
- NULL },
-
- { ngx_string("websocket_buffer"),
- NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_TCP_SRV_CONF_OFFSET,
- offsetof(ngx_tcp_websocket_conf_t, buffer_size),
- NULL },
-
- { ngx_string("websocket_connect_timeout"),
- NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_TCP_SRV_CONF_OFFSET,
- offsetof(ngx_tcp_websocket_conf_t, upstream.connect_timeout),
- NULL },
-
- { ngx_string("websocket_read_timeout"),
- NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_TCP_SRV_CONF_OFFSET,
- offsetof(ngx_tcp_websocket_conf_t, upstream.read_timeout),
- NULL },
-
- { ngx_string("websocket_send_timeout"),
- NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_msec_slot,
- NGX_TCP_SRV_CONF_OFFSET,
- offsetof(ngx_tcp_websocket_conf_t, upstream.send_timeout),
- NULL },
+ { ngx_string("websocket_pass"),
+ NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_tcp_websocket_pass,
+ NGX_TCP_SRV_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("websocket_buffer"),
+ NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_TCP_SRV_CONF_OFFSET,
+ offsetof(ngx_tcp_websocket_conf_t, buffer_size),
+ NULL },
+
+ { ngx_string("websocket_connect_timeout"),
+ NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_TCP_SRV_CONF_OFFSET,
+ offsetof(ngx_tcp_websocket_conf_t, upstream.connect_timeout),
+ NULL },
+
+ { ngx_string("websocket_read_timeout"),
+ NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_TCP_SRV_CONF_OFFSET,
+ offsetof(ngx_tcp_websocket_conf_t, upstream.read_timeout),
+ NULL },
+
+ { ngx_string("websocket_send_timeout"),
+ NGX_TCP_MAIN_CONF|NGX_TCP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_TCP_SRV_CONF_OFFSET,
+ offsetof(ngx_tcp_websocket_conf_t, upstream.send_timeout),
+ NULL },
ngx_null_command
};
@@ -120,7 +139,7 @@ ngx_module_t ngx_tcp_websocket_module = {
};
-void
+static void
ngx_tcp_websocket_init_session(ngx_connection_t *c, ngx_tcp_session_t *s)
{
ngx_tcp_websocket_ctx_t *pctx;
@@ -147,27 +166,19 @@ ngx_tcp_websocket_init_session(ngx_connection_t *c, ngx_tcp_session_t *s)
}
c->write->handler = ngx_tcp_websocket_dummy_write_handler;
- /*make the complier happy*/
- c->read->handler = ngx_tcp_websocket_dummy_read_handler;
c->read->handler = ngx_tcp_websocket_start_handler;
- ngx_add_timer(s->connection->read, cscf->timeout);
+ ngx_add_timer(c->read, cscf->timeout);
- return;
-}
-
-
-/* parse the websocket handshake packet */
-static void
-ngx_tcp_websocket_start_handler(ngx_event_t *ev)
-{
- ngx_connection_t *c;
- ngx_tcp_session_t *s;
+ if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+ ngx_tcp_finalize_session(s);
+ }
- c = ev->data;
- s = c->data;
+ if (c->read->ready) {
+ ngx_tcp_websocket_start_handler(c->read);
+ }
- ngx_tcp_websocket_init_upstream(c, s);
+ return;
}
@@ -205,6 +216,289 @@ ngx_tcp_websocket_dummy_read_handler(ngx_event_t *rev)
}
+static void
+ngx_tcp_websocket_start_handler(ngx_event_t *ev)
+{
+ ngx_connection_t *c;
+ ngx_tcp_session_t *s;
+ ngx_tcp_websocket_ctx_t *pctx;
+
+ c = ev->data;
+ s = c->data;
+
+ pctx = ngx_tcp_get_module_ctx(s, ngx_tcp_websocket_module);
+
+ pctx->parser = ngx_pcalloc(s->connection->pool, sizeof(http_request_parser));
+ if (pctx->parser == NULL) {
+ ngx_tcp_finalize_session(s);
+ return;
+ }
+
+ websocket_http_request_parser_init(pctx->parser, s);
+
+ c->read->handler = ngx_tcp_websocket_recv_handler;
+
+ ngx_tcp_websocket_recv_handler(ev);
+
+}
+
+
+static void
+websocket_http_request_parser_init(http_request_parser *hp, void *data)
+{
+ hp->data = data;
+ hp->request_method = request_method;
+ hp->request_uri = request_uri;
+ hp->fragment = fragment;
+ hp->request_path = request_path;
+ hp->query_string = query_string;
+ hp->http_version = http_version;
+ hp->http_field = http_field;
+ hp->header_done = header_done;
+
+ http_request_parser_init(hp);
+}
+
+
+static void
+request_method(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "METHOD: \"%V\"", &str);
+#endif
+}
+
+
+static void
+request_uri(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "URI: \"%V\"", &str);
+#endif
+}
+
+
+static void
+fragment(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "FRAMENT: \"%V\"", &str);
+#endif
+}
+
+
+static void
+request_path(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "PATH: \"%V\"", &str);
+#endif
+}
+
+
+static void
+query_string(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "QUERY: \"%V\"", &str);
+#endif
+}
+
+
+static void
+http_version(void *data, const signed char *at, size_t length)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str;
+ ngx_tcp_session_t *s = data;
+
+ str.data = (u_char *) at;
+ str.len = length;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "VERSION: \"%V\"", &str);
+#endif
+}
+
+
+static void
+http_field(void *data, const signed char *field,
+ size_t flen, const signed char *value, size_t vlen)
+{
+#if (NGX_DEBUG)
+ ngx_str_t str_field, str_value;
+ ngx_tcp_session_t *s = data;
+
+ str_field.data = (u_char *) field;
+ str_field.len = flen;
+
+ str_value.data = (u_char *) value;
+ str_value.len = vlen;
+
+ ngx_log_debug2(NGX_LOG_DEBUG_TCP, s->connection->log, 0,
+ "%V: %V", &str_field, &str_value);
+#endif
+}
+
+
+static void
+header_done(void *data, const signed char *at, size_t length)
+{
+ /*void */
+}
+
+
+static void
+ngx_tcp_websocket_recv_handler(ngx_event_t *ev)
+{
+ u_char *new_buf;
+ ssize_t size, n;
+ ngx_int_t rc;
+ ngx_connection_t *c;
+ ngx_tcp_session_t *s;
+ ngx_tcp_websocket_ctx_t *pctx;
+
+ c = ev->data;
+ s = c->data;
+
+ pctx = ngx_tcp_get_module_ctx(s, ngx_tcp_websocket_module);
+
+ while (1) {
+ n = s->buffer->end - s->buffer->last;
+ /*Not enough buffer? Enlarge twice*/
+ if (n == 0) {
+ size = s->buffer->end - s->buffer->start;
+ new_buf = ngx_palloc(c->pool, size * 2);
+ if (new_buf == NULL) {
+ goto websocket_recv_fail;
+ }
+
+ ngx_memcpy(new_buf, s->buffer->start, size);
+
+ s->buffer->pos = s->buffer->start = new_buf;
+ s->buffer->last = new_buf + size;
+ s->buffer->end = new_buf + size * 2;
+
+ n = s->buffer->end - s->buffer->last;
+ }
+
+ size = c->recv(c, s->buffer->last, n);
+
+#if (NGX_DEBUG)
+ ngx_err_t err;
+
+ err = (size >= 0) ? 0 : ngx_socket_errno;
+ ngx_log_debug3(NGX_LOG_DEBUG_TCP, ev->log, err,
+ "tcp websocket recv size: %d, client: %V #%d", size, &c->addr_text, c->fd);
+#endif
+
+ if (size > 0) {
+ s->buffer->last += size;
+ continue;
+ } else if (size == 0 || size == NGX_AGAIN) {
+ break;
+ }
+ else {
+ c->error = 1;
+ goto websocket_recv_fail;
+ }
+ }
+
+ rc = websocket_http_request_parser_execute(pctx->parser);
+
+ ngx_log_debug2(NGX_LOG_DEBUG_TCP, c->log, 0,
+ "tcp websocket parse rc: %d, fd: %d", rc, c->fd);
+
+ switch (rc) {
+ case NGX_AGAIN:
+ return;
+ case NGX_ERROR:
+ goto websocket_recv_fail;
+ case NGX_OK:
+ default:
+ ngx_tcp_websocket_init_upstream(c, s);
+ }
+
+ return;
+
+websocket_recv_fail:
+ ngx_log_error(NGX_LOG_ERR, ev->log, 0,
+ "recv websocket handshake packet error with client: %V #%d", &c->addr_text, c->fd);
+ ngx_tcp_finalize_session(s);
+}
+
+
+static ngx_int_t
+websocket_http_request_parser_execute(http_request_parser *hp)
+{
+ ssize_t n, offset, length;
+ ngx_int_t rc;
+ ngx_tcp_session_t *s;
+
+ s = hp->data;
+
+ if ((s->buffer->last - s->buffer->pos) > 0) {
+ offset = s->buffer->pos - s->buffer->start;
+ length = s->buffer->last - s->buffer->start;
+
+ n = http_request_parser_execute(hp, (signed char *)s->buffer->start, length, offset);
+ s->buffer->pos += n;
+
+ rc = http_request_parser_finish(hp);
+
+ if (rc == 0) {
+ return NGX_AGAIN;
+ }
+ else if (rc == 1){
+ return NGX_OK;
+ }
+ if (rc == -1) {
+ ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
+ "http request parse error with client: %V, recv data: %s",
+ &s->connection->addr_text, s->buffer->start);
+ return NGX_ERROR;
+ }
+ }
+
+ return NGX_AGAIN;
+}
+
+
static void
ngx_tcp_websocket_init_upstream(ngx_connection_t *c, ngx_tcp_session_t *s)
{
@@ -218,6 +512,9 @@ ngx_tcp_websocket_init_upstream(ngx_connection_t *c, ngx_tcp_session_t *s)
pctx = ngx_tcp_get_module_ctx(s, ngx_tcp_websocket_module);
+ c->write->handler = ngx_tcp_websocket_dummy_write_handler;
+ c->read->handler = ngx_tcp_websocket_dummy_read_handler;
+
if (ngx_tcp_upstream_create(s) != NGX_OK) {
ngx_tcp_finalize_session(s);
return;
@@ -232,12 +529,18 @@ ngx_tcp_websocket_init_upstream(ngx_connection_t *c, ngx_tcp_session_t *s)
pctx->upstream = &u->peer;
- pctx->buffer = ngx_create_temp_buf(s->connection->pool, pcf->buffer_size);
+ pctx->buffer = ngx_create_temp_buf(s->connection->pool,
+ (s->buffer->end - s->buffer->start));
if (pctx->buffer == NULL) {
ngx_tcp_finalize_session(s);
return;
}
+ /*
+ * move back to the start position, send the handshake
+ * packet to backend server */
+ s->buffer->pos = s->buffer->start;
+
ngx_tcp_upstream_init(s);
return;
@@ -291,21 +594,26 @@ ngx_tcp_upstream_websocket_proxy_init_handler(ngx_tcp_session_t *s, ngx_tcp_upst
ngx_add_timer(c->read, pcf->upstream.read_timeout);
ngx_add_timer(c->write, pcf->upstream.send_timeout);
- if (ngx_handle_read_event(s->connection->read, 0) != NGX_OK) {
- ngx_tcp_finalize_session(s);
- return;
- }
+ s->connection->read->ready = 1;
#if (NGX_TCP_SSL)
/* The ssl connection with client may not trigger the read event again,
* So I trigger it in this function. */
if (s->connection->ssl) {
ngx_tcp_websocket_proxy_handler(s->connection->read);
+ return;
}
#endif
+ if (ngx_handle_read_event(s->connection->read, 0) != NGX_OK) {
+ ngx_tcp_finalize_session(s);
+ return;
+ }
+
+ ngx_tcp_websocket_proxy_handler(s->connection->read);
+
return;
}
@@ -386,6 +694,11 @@ ngx_tcp_websocket_proxy_handler(ngx_event_t *ev)
do_write = ev->write ? 1 : 0;
+ if (b->pos != b->last) {
+ do_write = 1;
+ *read_bytes += b->last - b->pos;
+ }
+
ngx_log_debug4(NGX_LOG_DEBUG_TCP, ev->log, 0,
"tcp websocket proxy handler: %d, #%d > #%d, time:%ui",
do_write, src->fd, dst->fd, ngx_current_msec);
View
1 ngx_tcp_session.h
@@ -65,7 +65,6 @@ void ngx_tcp_finalize_session(ngx_tcp_session_t *s);
ngx_tcp_cleanup_t * ngx_tcp_cleanup_add(ngx_tcp_session_t *s, size_t size);
ngx_int_t ngx_tcp_access_handler(ngx_tcp_session_t *s);
-void ngx_tcp_proxy_init_session(ngx_connection_t *c, ngx_tcp_session_t *s);
ngx_int_t ngx_tcp_log_handler(ngx_tcp_session_t *s);
extern ngx_module_t ngx_tcp_proxy_module;
View
1 ngx_tcp_upstream_check.c
@@ -768,7 +768,6 @@ ngx_tcp_check_http_parse(ngx_tcp_check_peer_conf_t *peer_conf)
http_response_parser *hp;
ngx_tcp_upstream_srv_conf_t *uscf;
-
uscf = peer_conf->conf;
ctx = peer_conf->check_data;
hp = ctx->parser;
View
20 test/websocket/server.rb
@@ -0,0 +1,20 @@
+require 'em-websocket'
+
+EventMachine.run {
+
+ EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 1984) do |ws|
+ ws.onopen {
+ puts "WebSocket connection open"
+
+ # publish message to the client
+ ws.send "Hello Client"
+ }
+
+ ws.onclose { puts "Connection closed" }
+ ws.onmessage { |msg|
+ puts "Recieved message: #{msg}"
+ ws.send "Pong: #{msg}"
+ }
+ end
+
+}

0 comments on commit 4be6a0e

Please sign in to comment.