mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

Closing connection #212

Closed tselishev-semen closed 9 years ago

tselishev-semen commented 9 years ago

Hi all. I have a problem, when the user connected from another country. Server located in Russia, the client is in Italy. There is a very slow internet.

Сonnection is established( fired 'connect' event), but then stops working. On the client (in browser) an error 500 (Internal Server Error) On the netty server

 ERROR com.corundumstudio.socketio.transport.PollingTransport - fc041f82-abd8-405b-9012-2ea1c38568b6 is not registered. Closing connection

nginx log:

2015/02/10 11:25:34 [info] 19760#0: *88 client #.###.##.### closed keepalive connection

I use NGINX as a WebSocket Proxy(http://nginx.com/blog/websocket-nginx). I tried to increase the timeouts:

    keepalive_timeout 70s
    send_timeout 60s;
    client_body_timeout 72s;
    client_header_timeout 72s;

but it did not help:((

I need you help

tselishev-semen commented 9 years ago

To reproduse error, i'am use slow italian proxy 82.85.8.99:8080.

mrniko commented 9 years ago

have you tried to change netty-socketio timeouts?

pablojr commented 9 years ago

In order to simulate (under controlled conditions) a slow network connection in your test environment, you may want to take a look at this tool: Sloppy

tselishev-semen commented 9 years ago

have you tried to change netty-socketio timeouts?

@mrniko, I tried:

      Configuration config = new Configuration();
       //...
       config.setUpgradeTimeout(10000000);
       config.setPingTimeout(10000000);

But it did not help.

mrniko commented 9 years ago

you forgot to set long pingInterval

tselishev-semen commented 9 years ago

I added

    config.setUpgradeTimeout(10000000);
        config.setPingTimeout(10000000);
        config.setPingInterval(10000000);

It did not help

tselishev-semen commented 9 years ago

@pablojr, Thanks, I'll try to use it in the near time

piscui commented 9 years ago

Try adding this directive in your nginx's server context: proxy_read_timeout 86400s;

tselishev-semen commented 9 years ago

@piscui, thanks for the idea. I will try to set this option. But now I can not reproduce the bug. I close this issue.

blogsit commented 9 years ago

I have a problem ,the same to you ? solution?

blogsit commented 9 years ago

error message

ERROR com.corundumstudio.socketio.transport.PollingTransport - 3a129585-34d9-45cb-b82a-cd55365a73fc is not registered. Closing connection

piscui commented 9 years ago

In addition to my previous suggestion to adding proxy_read_timeout 86400s; to the nginx config, in my case it also helped tweaking the OS and nginx further, not 100% bullet proof but it reduced the error count significantly.

You may need to increase your OS and nginx max open files limit (check your nginx error logs to confirm). Do a ulimit -n and increase the value if needed (ie. ulimit -n 30000), then add worker_rlimit_nofile 30000; to your nginx config.

Also increase the worker_processes value to 2 * number of processors/cores and worker_connections to a value close to worker_rlimit_nofile (ie. 20000 going by the previous example). Don't forget to reload nginx.

Last but not least, make use you're using the latest version of socket.io.js.

I hope it helps.

blogsit commented 9 years ago

thanks @piscui
Using this method “Try adding this directive in your nginx's server context: proxy_read_timeout 86400s;” Solved the problem, because nginx timeout set 3s . Using this nginx config Solved the problem. location /epush { proxy_pass http://epush_socket; proxy_buffering off; proxy_read_timeout 30s; }

tselishev-semen commented 9 years ago

In the clien side(http://socket.io/docs/client-api/) has the option of timeout

io.connect(connectUrl, {reconnectionDelay: 3000, timeout: 15000})

I do not know what helped me, but I think it can also help