-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket.io disconnect with ping timeout randomly #2769
Comments
Have you tried listening to any emitted error events? http://stackoverflow.com/questions/24224287/list-of-socket-io-events |
I have the same problem did you figure this out ? |
@jitendrapawar are you able to reproduce consistently? |
No it's not repeatedly, it's randomly getting disconnected with ping
timeout.
…On Jan 10, 2017 7:50 PM, "Damien Arrachequesne" ***@***.***> wrote:
@jitendrapawar <https://github.com/jitendrapawar> are you able to
reproduce consistently?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2769 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANP7JpiqxkTpZlc5CsayjIZf9GAqURLiks5rQ5OsgaJpZM4K9hrg>
.
|
|
Same issue here. No other errors are emitted. Seems to be totally random. |
I disable the network, and enable it immediately. About 1 minute later, the server gets a 'ping timeout' problem. |
author said that: |
I have just come across this issue as well. Our app has run fine without these disconnects for over a year, but now experiencing random disconnects. In debug, reason for disconnect is "ping timeout" and clients seem to have no issue reconnecting. The only thing I can possibly narrow it down to so far is a new version of Google Chrome. Chrome 63 seems to have no issues, but users on 64 are the ones experiencing the disconnects and I have no idea why |
I'm facing the exact same problem and I'm on Chrome 63 @jstelz. Does anyone found the problem or a solution? |
That may be linked to #5082. |
@darrachequesne In my case it is definitely linked to the issue of client-side timers throttled in background tabs (at least in chrome, I have not yet tested it in other browsers). |
@sirudog well, that's quite a big breaking change! I think we'll have to do that though... |
I have this problem with a game I'm working on. When I set the server to When I set the server to |
For anyone suffering random timeouts, try changing the default engine.io "transport upgrade timeout" (upgradeTimeout). After reconnecting and receiving large amount of data, the socket seemed unresponsive, debugging engine.io didn't show any errors, just the socket trying to upgrade transport every time the client reconnects. example server:
You can read more about engine.io here: |
hi
Hi, I tried it but got still many disconnects: 15:10:57,270 urbanGUI INFO connected |
@kllr
Another thing you can try is to drop transport upgrade
|
I get same problem with socket.io 2.2. It randomly brake after some period of time and start reconnecting. Error is Is there any way to make sure connection is stabile and never brake? Myabe some browser or something like that? |
Hi, Greetings |
same problem happening to me, i m on socket.io 2.2.0 , and when on my website when a client sends an image in base64 to the server, and image is big, then this causes the image sender client to get ping timeout error and disconnects the client. plz let us know if anyone found any fix. |
Can you guys try by settings the pingTimeout to be higher than the pingInterval, like suggested here: Server:
Client:
Default pingInterval is 25000ms.
|
There is one undocumented (?) problematic behavior regarding timeouts: if server sends big packet which takes longer than timeout interval to transmit, that leads to timeout and disconnect. Only way to fix this is to make sure you send only relatively small packets. This is a problem as it means that you need to pay (too) much attention on your server logic so the data is always within the limits - and - as the connection speed is unknown factor, it's hard to fix this completely. I'd suggest to adjust the timeout logic slightly to overcome this. |
Some more info about my issues. @IIaakso what is the recommended ping timeout settings, mine r these as of now: My client js: My server settings: still facing same issue on "socket.io": "2.2.0", |
Same issue as @FaizanZahid . It just randomly disconnect with with ping timeout... |
Same issue, and my setup really doesn't differ from yours (forceNew: true, being the most important part imo) I'm upgrading from an antique socket.io 1.x with node 6.x setup to socket.io 2.2 and node 12.x, on both sending and receiving servers of the test. Prior to the upgrade I could launch around 12k concurrent connections from the source server (running the client) to the destination server (running the io server). The obvious system limits, firewall limits etc were checked and tuned prior to the update, so both "sending" and "receiving" servers should not be cause for issues or limitations. But after upgrading to socket.io 2.2, I get random ping timeouts when launching about 2.5k concurrent connections... *edit: no data is being transmitted in my test app, so it's not a data length, or content type issue. the clients only connects to the server, which performs custom auth for the clients, and if auth is successful, the clients wait for a server event. So any insight on possible cause would be highly appreciated ;) |
From the tests I performed on my setup (FreeBSD 11.2, node 12.3.x), here are the results I can observe and replicate: socket.io-client version | socket.io version | result So the issue seems to be in the client section of socket-io-client 2.2, or at least 2.x client branch... |
* The connection randomly disconnects :\ * This makes the image kinda freeze until the server/client reconnects or smtn ig * appears to be because of a lot of data throughput?? idk tbh * maybe look into socketio/socket.io#2769
Any solution for this?? It is not problem with number of connections in my case, it just randomly disconnect after few hours of inactivity with ping timeout error... |
I have a similar problem, is the reason known? |
@berksafran I'm facing same in android only, Could you please let me know how did you fixed it ? |
Well, Unfortunately I couldn't fixed this issue but I saw that this problem is only in development process. When you release your application and try with The other solution that I found it, is uploading your socket.io server to any cloud server. (heroku, digitalocean etc.) After uploading, you should set your connection address to url of cloud server. I have tried it and it's working now. If any question, you can text me on here. Good luck. |
Anyone find the solution ? Updated: I tested after deploying my app, it works. |
Hi everyone, My server is hosted on heroku. And I am facing these random ping timeouts. The ping timeouts occur even more frequently when I open my app on mobile. Any solution that I can try? Thanks |
@sukalyansen123 From my debugging long ago, I noticed that it fails to upgrade transport and it times out. Try with websockets only:
|
@sukalyansen123 - I had a similar issue and for me actually setting the default timeouts explicitly seemed to help. SERVER SIDE: BEFORE: AFTER: }); |
Thanks. I tried doing this but still doesnt help. Now again on mobile socket disconnection happens, sometimes due to ping timeout and sometimes due to transport close. I am not sure if this is due to drop in internet connections, but again how am I supposed to handle this. |
Here is what my client side looks like if this helps - I only connect using websocket protocol
` |
Thanks again. Also wanted to know how you're handling the disconnect event from the client side. |
This seems to help a bit. However right now sockets are getting disconnected if kept idle for sometime with transport close. Would sending heartbeats at regular time intervals be a good solution? |
i have same problem. but i using socket for my online game. |
Try this code at server side
Here pingInterval is importantant, Keep it low, I tried various values and found 25 sec is good to keep socket keep pinging before it get timeout. Main issue is there if within 60 sec there is no ping/pong then it will disconnect and try to auto reconnect. Also I found pingTimeout at server side and timeout and client side not able to help to disconnect the socket in 60 sec. Its happening due to chrome latest version 83.* |
As suggested above, we will revert the ping/pong mechanism in Socket.IO v3: https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4 |
I have also started to face same issue. I am using version socket.io version |
Our project just updated node to v12. After that update we also get the disconnection because of ping timeout :| Here is a list of times when the disconnects occured: 11:06:59 Our settings: |
Hey! had the same problem. Socket.io versions 2.3.0 (same versions on client and server). |
Matching the versions for server and client solves the problem for me. I've tested with V 3.0.4 & 2.3.0 |
I had a similar problem. This bug happened randomly. |
This value was updated from 60000 to 5000 in [1], included in `engine.io@3.2.0` (Feb 2018). The reasoning back then: Some users experienced long delays between disconnection on the server-side and on the client-side. The "disconnect" event would take a long time to fire in the browser, probably due to a timer being delayed. Hence the change. That being said, the current value (5s) now causes unexpected disconnections when a big payload is sent over a slow network, because it prevents the ping-pong packets from being exchanged between the client and the server. This can also happen when a synchronous task blocks the server for more than 5 seconds. The new value (20s) thus seems like a good balance between quick disconnection detection and tolerance to various delays. Note: pingInterval + pingTimeout is still below the threshold of React Native, which complains if a timer is set with a delay of more than 1 minute. [1]: 65b1ad1 Related: - socketio/socket.io#2770 - socketio/socket.io#2769 - socketio/socket.io#3054 - socketio/socket.io#3376
There was two changes in latest releases that should fix this issue:
Reference: https://socket.io/blog/engine-io-4-release/#Heartbeat-mechanism-reversal
Reference: https://socket.io/docs/v4/migrating-from-3-x-to-4-0/#The-default-value-of-pingTimeout-was-increased I think we can now close this. Please reopen if needed. |
This value was updated from 60000 to 5000 in [1], included in `engine.io@3.2.0` (Feb 2018). The reasoning back then: Some users experienced long delays between disconnection on the server-side and on the client-side. The "disconnect" event would take a long time to fire in the browser, probably due to a timer being delayed. Hence the change. That being said, the current value (5s) now causes unexpected disconnections when a big payload is sent over a slow network, because it prevents the ping-pong packets from being exchanged between the client and the server. This can also happen when a synchronous task blocks the server for more than 5 seconds. The new value (20s) thus seems like a good balance between quick disconnection detection and tolerance to various delays. Note: pingInterval + pingTimeout is still below the threshold of React Native, which complains if a timer is set with a delay of more than 1 minute. [1]: 65b1ad1 Related: - socketio/socket.io#2770 - socketio/socket.io#2769 - socketio/socket.io#3054 - socketio/socket.io#3376 Backported from 5a7fa13
V 3.0.4这个版本确实没有pingTimeout了,感谢宝贵经验 |
For future readers: Please check https://socket.io/docs/v4/troubleshooting-connection-issues/ |
we have a real time chat application, that uses socket.io, node.js, mongodb etc. Chat is working very fine except one issue & that is as follows
Some time in between while chatting user are getting disconnected with ping timeout. As I checked there was no problem with internet connection & also there is no logs on re-connection attempts. It directly gets disconnected.
OS - Ubuntu 14.04/AWS EC2
socket.io version on server - 1.6.0
Node version - v0.10.25
Please let us know what could be the problem. Also let me know if you need any other details
The text was updated successfully, but these errors were encountered: