
socket.io-client-java: v0.7.0
socket.io(nodejs): v1.3.7
sticky-session: v0.1.0
nginx: v1.6.2
mobile network: edge, ping 1s-6s (sometimes up to 16sec).
connecting over http.
Typical scenario:
Our app has subscribed on events: connected, disconnected, reconnect and logs them. We are using https://logentries.com/ to collect logs from out clients and there are about 50 connections for 2 hours. at the same time to the server 8 in the second connections it has been reported.
We store our connection in service.
Can you post client code here?
I wonder if it's because IO.socket() returns new connections if a same host and path was specified, from 0.7.0.
socket1 = IO.socket("http://localhost:8080/foo");
socket2 = IO.socket("http://localhost:8080/foo");
// socket1 != socket2 on 0.7.0
// socket1 == socket2 on 6.x and earlier
Also, 7 days ago we had socket.io-client 0.5.2 and there were 3k connections per day. 4 days ago we upgraded lib to 0.6.3 and there were 30k connections per day. day before yesterday we upgraded lib to 0.7.0 and its 100k connections per day. Ok, our developer will post code in several mins.
public abstract class BaseSocketService1 extends Service implements SocketStatusListener, SocketClient {
public static final long TIMEOUT = 20 * 1000;
Socket mSocket;
private void initConnection() {
try {
log("Init mSocket " + PreferenceUtils.getEnv(this));
IO.Options options = new IO.Options();
options.reconnectionDelay = 0;
options.reconnectionAttempts = 1000;
options.reconnection = true;
mSocket = IO.socket(PreferenceUtils.getEnv(this), options);
mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("SOCKET TIMEOUT");
reconnect();
}
});
mSocket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("Disconnect " + mSocket.id());
onSocketDisconnect();
}
});
mSocket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("Connect " + mSocket.id());
onSocketConnect();
}
});
mSocket.on(Socket.EVENT_RECONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("Reconnect");
}
});
mSocket.connect();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public void reconnect() {
disconnect();
initConnection();
}
public void disconnect() {
log("disconnect in service");
mSocket.off();
mSocket.disconnect();
mSocket = null;
}
}
Also sometimes we can see in logs:
Connected null
Disconnected null
notice: it is looks like client make new connection every 100 ms
I'm not sure if it's the cause, but you shouldn't call mSocket.off();, because it will remove all listeners including internally defined events.
Ok, thank you we will try it now. I will be grateful if you answer the question: what do you think about our timeouts and what would you recommend for such conditions (mobile network: edge, ping 1s-6s (sometimes up to 16sec)). Thank you.
So we have tested it. Your suggestion doesn't work.
I found out interesting behaviour when i was testing app.
Test: connect over Edge to server and in same time use phone like ad-hoc for ipad. on ipad i was watching some videos on youtube,
So, i was watching in server logs, where i saw that i was connected:
2016-02-06T22:02:36.591Z - debug: Client k28R6ODk7EJIRuqKAAAX connected 95.153.132.29
everything was great, sometimes internet was bad, but all packages are reached server.
and then after 10 mins, i saw this:
2016-02-06T22:03:57.598Z - debug: Client E7a_RG96BccmFNkMAAAB connected 95.153.132.29
and again:
2016-02-06T22:04:36.773Z - debug: Client GIrdSHvTz2UitBlXAACT connected 95.153.132.29
That;s all. There is no disconnections .
So, i was wonder, was there any activity on these connections?
FIrst connection:
2016-02-06T22:02:39.535Z - silly: Responding on ping with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:02:46.086Z - silly: Responding on getAppVersion with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:02:52.123Z - silly: Responding on auth:session with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:01.459Z - silly: Responding on ping with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:01.462Z - silly: Responding on orders:getStatuses with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:01.464Z - silly: Responding on state:changed with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:04.986Z - silly: Responding on profile:retrieve with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:11.655Z - silly: Responding on ping with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:11.658Z - silly: Responding on orders:getStatuses with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:11.690Z - silly: Responding on state:changed with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:14.460Z - silly: Responding on orders:getStatuses with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:14.461Z - silly: Responding on orders:checkForUpdates with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:14.463Z - silly: Responding on orders:retrieve with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:18.414Z - silly: Responding on profile:getState with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:20.433Z - silly: Responding on orders:getStatuses with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:25.343Z - silly: Responding on position:changed with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:28.567Z - silly: Responding on ping with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:33.169Z - silly: Responding on orders:getStatuses with: k28R6ODk7EJIRuqKAAAX
2016-02-06T22:03:33.170Z - silly: Responding on orders:checkForUpdates with: k28R6ODk7EJIRuqKA
It lookls like yes. first connection still alive.ok, what is about second connection:
2016-02-06T22:04:05.468Z - silly: Responding on getAppVersion with: E7a_RG96BccmFNkMAAAB
2016-02-06T22:04:10.726Z - silly: Responding on auth:session with: E7a_RG96BccmFNkMAAAB
2016-02-06T22:04:11.716Z - silly: Responding on profile:retrieve with: E7a_RG96BccmFNkMAAAB
2016-02-06T22:05:36.685Z - debug: Client E7a_RG96BccmFNkMAAAB disconnected 95.153.132.29
Second connection was trying to authorize and retrieve profile and it was successfull attempt and then it was disconnected. Note: First connection is still alive
Last one:
2016-02-06T22:04:40.272Z - silly: Responding on getAppVersion with: GIrdSHvTz2UitBlXAACT
2016-02-06T22:04:49.446Z - silly: Responding on ping with: GIrdSHvTz2UitBlXAACT
It also was try get current app version, also successfull attempt.
Now first and last connection is still alive and they are active now.
After 40 mins of my inactivity, i still have 2 active connections. Now i try to emit signals, and i can't. because timeout on request and server is not responding.
Now, i have restarted app.I will remind you, that i have 2 connections with ids: k28R6ODk7EJIRuqKAAAX and GIrdSHvTz2UitBlXAACT. And what i see in logs:
2016-02-06T22:47:58.090Z - debug: Client GIrdSHvTz2UitBlXAACT disconnected 95.153.132.29
2016-02-06T22:47:58.650Z - debug: Client tnLybIP-dj89EmCoAApz connected 95.153.132.29
So, i am asking myself, where is disconnect for k28R6ODk7EJIRuqKAAAX ?
Also now everything is fine.
I wonder if connections are properly managed according to life cycle of Service. I'm not so familiar with Android Service, but basically, you'd have to make sure that only a connection exists at a time.
I have theory, that it is reproduced on weak internet with high load on network. For example, you are running your up over edge and watching youtube in the same time. So app can't connect to server quick, these connections maybe are queued and as soon as internet is working good again, all of them are sent to server.
@nkzawa Now i have very bad internet
Android:
02-07 16:30:59.764 com.CatTaxi I/ApiService: KITTY Init mSocket http://driver.cattaxi.ru
02-07 16:30:59.770 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:30:59.770 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:30:59.771 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:31:09.793 com.CatTaxi D/.socket.engineio.client.Socket: socket error io.socket.engineio.client.EngineIOException: xhr poll error
02-07 16:31:09.793 com.CatTaxi D/io.socket.client.Manager: connect_error
02-07 16:31:09.793 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:31:09.802 com.CatTaxi D/io.socket.client.Manager: will wait 1350ms before reconnect attempt
02-07 16:31:11.157 com.CatTaxi D/io.socket.client.Manager: attempting reconnect
02-07 16:31:11.158 com.CatTaxi I/ApiService: KITTY Reconnecting null
02-07 16:31:11.159 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:31:11.159 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:31:11.160 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:31:21.196 com.CatTaxi D/.socket.engineio.client.Socket: socket error io.socket.engineio.client.EngineIOException: xhr poll error
02-07 16:31:21.196 com.CatTaxi D/io.socket.client.Manager: connect_error
02-07 16:31:21.197 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:31:21.204 com.CatTaxi D/io.socket.client.Manager: reconnect attempt error
02-07 16:31:21.206 com.CatTaxi D/io.socket.client.Manager: will wait 1310ms before reconnect attempt
02-07 16:31:22.524 com.CatTaxi D/io.socket.client.Manager: attempting reconnect
02-07 16:31:22.525 com.CatTaxi I/ApiService: KITTY Reconnecting null
02-07 16:31:22.526 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:31:22.526 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:31:22.527 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:31:36.251 com.CatTaxi D/.socket.engineio.client.Socket: socket received: type 'open', data '{"sid":"CJVmSzsiO_-rfAmJAB5N","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}'
02-07 16:31:36.274 com.CatTaxi D/io.socket.client.Manager: open
02-07 16:31:36.275 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:31:36.276 com.CatTaxi D/io.socket.client.Socket: transport is open - connecting
02-07 16:31:36.276 com.CatTaxi D/io.socket.client.Manager: reconnect success
02-07 16:31:36.277 com.CatTaxi I/ApiService: KITTY Reconnect
02-07 16:32:01.319 com.CatTaxi D/.socket.engineio.client.Socket: writing ping packet - expecting pong within 60000ms
02-07 16:32:11.386 com.CatTaxi D/.socket.engineio.client.Socket: socket error io.socket.engineio.client.EngineIOException: xhr post error
02-07 16:32:11.387 com.CatTaxi D/io.socket.client.Manager: error
02-07 16:32:11.402 com.CatTaxi D/io.socket.client.Manager: io.socket.engineio.client.EngineIOException: xhr post error
at io.socket.engineio.client.Transport.onError(Transport.java:64)
at io.socket.engineio.client.transports.PollingXHR.access$000(PollingXHR.java:18)
at io.socket.engineio.client.transports.PollingXHR$4$1.run(PollingXHR.java:89)
at io.socket.thread.EventThread$2.run(EventThread.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:838)
Caused by: java.net.SocketTimeoutException: failed to connect to driver.cattaxi.ru/95.213.134.66 (port 80) after 10000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:176)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:860)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:205)
at io.socket.engineio.client.transports.PollingXHR$Request$1.run(PollingXHR.java:206)
at java.lang.Thread.run(Thread.java:838)聽
02-07 16:32:11.405 com.CatTaxi D/io.socket.client.Manager: onclose
02-07 16:32:11.405 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:32:11.406 com.CatTaxi D/io.socket.client.Socket: close (transport error)
02-07 16:32:11.410 com.CatTaxi D/io.socket.client.Manager: will wait 1299ms before reconnect attempt
02-07 16:32:12.714 com.CatTaxi D/io.socket.client.Manager: attempting reconnect
02-07 16:32:12.715 com.CatTaxi I/ApiService: KITTY Reconnecting null
02-07 16:32:12.716 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:32:12.717 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:32:12.718 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:32:22.770 com.CatTaxi D/.socket.engineio.client.Socket: socket error io.socket.engineio.client.EngineIOException: xhr poll error
02-07 16:32:22.771 com.CatTaxi D/io.socket.client.Manager: connect_error
02-07 16:32:22.772 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:32:22.784 com.CatTaxi D/io.socket.client.Manager: reconnect attempt error
02-07 16:32:22.785 com.CatTaxi D/io.socket.client.Manager: will wait 1324ms before reconnect attempt
02-07 16:32:24.134 com.CatTaxi D/io.socket.client.Manager: attempting reconnect
02-07 16:32:24.144 com.CatTaxi I/ApiService: KITTY Reconnecting null
02-07 16:32:24.150 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:32:24.150 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:32:24.153 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:32:34.181 com.CatTaxi D/.socket.engineio.client.Socket: socket error io.socket.engineio.client.EngineIOException: xhr poll error
02-07 16:32:34.181 com.CatTaxi D/io.socket.client.Manager: connect_error
02-07 16:32:34.182 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:32:34.182 com.CatTaxi D/io.socket.client.Manager: reconnect attempt error
02-07 16:32:34.185 com.CatTaxi D/io.socket.client.Manager: will wait 5000ms before reconnect attempt
02-07 16:32:39.194 com.CatTaxi D/io.socket.client.Manager: attempting reconnect
02-07 16:32:39.209 com.CatTaxi I/ApiService: KITTY Reconnecting null
02-07 16:32:39.210 com.CatTaxi D/io.socket.client.Manager: readyState CLOSED
02-07 16:32:39.210 com.CatTaxi D/io.socket.client.Manager: opening http://driver.cattaxi.ru:80/
02-07 16:32:39.212 com.CatTaxi D/io.socket.client.Manager: connection attempt will timeout after 20000
02-07 16:32:46.438 com.CatTaxi D/.socket.engineio.client.Socket: socket received: type 'open', data '{"sid":"qziWT0-CK2kaGj_GAB-z","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}'
02-07 16:32:46.439 com.CatTaxi D/io.socket.client.Manager: open
02-07 16:32:46.439 com.CatTaxi D/io.socket.client.Manager: cleanup
02-07 16:32:46.441 com.CatTaxi D/io.socket.client.Socket: transport is open - connecting
02-07 16:32:46.446 com.CatTaxi D/io.socket.client.Manager: reconnect success
02-07 16:32:46.447 com.CatTaxi I/ApiService: KITTY Reconnect
NodeJS:
2016-02-07T13:31:35.315Z - debug: Client CJVmSzsiO_-rfAmJAB5N connected 95.153.132.4
2016-02-07T13:32:42.137Z - debug: Client qziWT0-CK2kaGj_GAB-z connected 95.153.132.4
2016-02-07T13:33:00.315Z - debug: Client CJVmSzsiO_-rfAmJAB5N disconnected 95.153.132.4
2016-02-07T13:34:07.136Z - debug: Client qziWT0-CK2kaGj_GAB-z disconnected 95.153.132.4
These logs look no problem ? Can you provide a simple code which I can reproduce the issue ?
Ok, i will write small application that reproduce this error
I have another problem now. I can't connect to server.
Logs:
02-10 18:49:52.774 com.CatTaxi I/ApiService: KITTY Init mSocket http://driver.cattaxi.ru
02-10 18:49:52.787 com.CatTaxi I/ApiService: KITTY CONNECTING
02-10 18:49:56.384 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=6278 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=5338 ms
02-10 18:49:57.265 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:49:59.916 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:09.920 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:15.456 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
02-10 18:50:17.268 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:50:18.470 com.CatTaxi D/.socket.engineio.client.Socket: probe transport 'websocket' pong
02-10 18:50:19.926 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:21.430 com.CatTaxi D/.socket.engineio.client.Socket: writing ping packet - expecting pong within 60000ms
02-10 18:50:25.867 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=2301 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=1361 ms
02-10 18:50:29.930 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:37.273 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:50:38.600 com.CatTaxi I/ApiService: gps no detect!
02-10 18:50:38.803 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=4860 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=3897 ms
02-10 18:50:39.936 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:48.507 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=598 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=659 ms
02-10 18:50:49.941 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:50:57.279 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:50:59.665 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=1511 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=2080 ms
02-10 18:50:59.947 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:09.307 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=601 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=603 ms
02-10 18:51:09.952 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:17.286 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:51:19.424 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=1138 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=1068 ms
02-10 18:51:19.957 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:21.442 com.CatTaxi I/ApiService: Disconnect null
02-10 18:51:28.602 com.CatTaxi I/ApiService: gps no detect!
02-10 18:51:29.962 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:30.787 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=1298 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=2311 ms
02-10 18:51:37.292 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:51:39.967 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:40.723 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=1556 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=887 ms
02-10 18:51:49.973 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:51:50.683 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=859 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=50 time=916 ms
02-10 18:51:57.298 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:51:59.978 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:52:09.735 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
02-10 18:52:09.984 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:52:17.303 com.CatTaxi I/ApiService: KITTY Emit Start orders:checkForUpdates {"ordersIds":[]}
02-10 18:52:18.603 com.CatTaxi I/ApiService: gps no detect!
02-10 18:52:19.989 com.CatTaxi I/ApiService: KITTY Emit Start orders:getStatuses {"ordersIds":[]}
02-10 18:52:28.776 com.CatTaxi I/ApiService: PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=10933 ms
It has been started at 18:49:52.774, and it is going still (19:25:23.288) (30 mins already!).
There is no ERRORS has been emitted.
Code:
mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY SOCKET TIMEOUT");
reconnect();
}
});
mSocket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("Disconnect " + mSocket.id());
onSocketDisconnect();
if (isConnectivityRecieverRegister) {
isConnectivityRecieverRegister = false;
unregisterReceiver(connectivityReceiver);
}
if (manualReconnecting) {
manualReconnecting = false;
initConnection();
}
if (disconnectTimer != null) {
disconnectTimer.cancel();
}
}
});
mSocket.on(Socket.EVENT_RECONNECTING, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY Reconnecting " + mSocket.id());
}
});
mSocket.on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY error");
isConnected = false;
reconnect();
}
});
mSocket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY Connect " + mSocket.id());
//connectionWasDetect();
isConnected = true;
onSocketConnect();
isConnectivityRecieverRegister = true;
registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
});
mSocket.on(Socket.EVENT_RECONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
manualReconnecting = false;
log("KITTY Reconnect");
}
});
mSocket.on(Socket.EVENT_CONNECTING, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY CONNECTING");
}
});
mSocket.on(Socket.EVENT_ERROR, new Emitter.Listener() {
@Override
public void call(Object... args) {
log("KITTY Error");
if (!mSocket.connected()) {
reconnect();
}
}
});
I am waiting for Socket.EVENT_CONNECT_TIMEOUT. If there is a bug, i will create my timer for it. Like:
connectTimer.schedule(new TimerTask() {
@Override
public void run() {
initConnection();
}
}, 24 * 1000);
And in logs we can see
02-10 18:51:21.442 com.CatTaxi I/ApiService: Disconnect null
But socket is not connected yet.
Disconnect was happend, after two minutes. Meanwhile in code we have this:
options.timeout = 20 * 1000;
hi , i am using version 0.6.3 and also have this issue, every second automatically create new socket connection and i don't know why
Hey I have similar issue. There is a case when the server tries to send large amount of data (~50K) to the client, somehow the client couldn't handle that amount of data in a slow network (not sure why, does not happen on fast connections) and a TCP Zero Window happens. When the zero window happens, the connection becomes stale, nothing more received by the client until the ping/pong timeout and the client tries to reconnect to server.
I'm not sure if it's related to the problem here, but I think fresh opinion would be good for diagnosing both of our problems.
In some case, my socket.io client enters a strange situation. It keeps reconnecting, and get error ping timeout. Latency is normal, tcp package gives error like sessionId not found, it actually upgrades fail.
With nodejs v2.0.4 and java-client v1.0.0, java-client cannot open beyond 5 connections. More than 5 will get error ping timeout.
@zyf0330 This will solve the issue:
val disatcher = new Dispatcher()
disatcher.setMaxRequests(5000)
disatcher.setMaxRequestsPerHost(5000)
val okHttpClient = new OkHttpClient.Builder()
.connectionPool(new ConnectionPool(5000, 5, TimeUnit.MINUTES))
.dispatcher(disatcher)
.build()
IO.setDefaultOkHttpWebSocketFactory(okHttpClient)
IO.setDefaultOkHttpCallFactory(okHttpClient)
val socket = IO.socket(url, opts);
I am also having problems with multiple connections.When debugging I get the listening result from socket.emit with null. It looks like in JSONObject there is no json file, it's null
Most helpful comment
@zyf0330 This will solve the issue: