sockjs / sockjs-erlang

WebSocket emulation - Erlang server
http://sockjs.org
Other
266 stars 120 forks source link

Slow websocket consumer problem #41

Open majek opened 11 years ago

majek commented 11 years ago

SockJS-erlang fails on slow websocket consumer.

For example:

=ERROR REPORT==== 26-Nov-2012::14:20:55 ===
** Handler sockjs_cowboy_handler terminating in websocket_handle/3
   for the reason exit:{noproc,
                           {gen_server,call,
                               [<0.158.0>,{received,[<<"18">>]},infinity]}}
** Message was {text,<<"[\"18\"]">>}
** Options were {service,"/amplify",#Fun<cowboy_test_server.2.61145267>,state,
                         "http://cdn.sockjs.org/sockjs-0.2.js",false,true,
                         5000,25000,131072,5000,
                         #Fun<sockjs_handler.0.34008514>}
** Handler state was {websocket,<0.158.0>,{#Ref<0.0.0.8840>,5000}}
** Request was {http_req,#Port<0.2609>,cowboy_tcp_transport,keepalive,
                         <0.157.0>,'GET',
                         {1,1},
                         {{127,0,0,1},59316},
                         [<<"localhost">>],
                         undefined,<<"localhost">>,8081,
                         [<<"amplify">>,<<"0">>,<<"0">>,<<"websocket">>],
                         [<<"0">>,<<"0">>,<<"websocket">>],
                         <<"/amplify/0/0/websocket">>,undefined,<<>>,[],
                         [{<<"Sec-Websocket-Version">>,<<"13">>},
                          {<<"Sec-Websocket-Key">>,
                           <<"FVKay/apSU2ZytGQBD2aBw==">>},
                          {<<"Origin">>,<<"localhost:8081">>},
                          {'Host',<<"localhost">>},
                          {'Connection',<<"Upgrade">>},
                          {'Upgrade',<<"websocket">>}],
                         [{'Upgrade',[<<"websocket">>]},
                          {'Connection',[<<"upgrade">>]}],
                         undefined,
                         [{websocket_version,13}],
                         waiting,<<>>,done,[],<<>>,
                         {#Fun<cowboy_http.urldecode.2>,crash}}
** Stacktrace: [{gen_server,call,3},
                {sockjs_session,received,2},
                {sockjs_ws_handler,session_received,2},
                {sockjs_cowboy_handler,websocket_handle,3},
                {cowboy_http_websocket,handler_call,7},
                {cowboy_http_protocol,upgrade_protocol,3}]

To reproduce pip install websocket-client and:

from websocket import create_connection
ws = create_connection("ws://localhost:8081/amplify/0/0/websocket")

result =  ws.recv()
print "Received '%s'" % result

for i in range(10000):
    ws.send('["18"]')

#    ws.send('["18"]')
result =  ws.recv()