floatinghotpot / socket.io-unity

socket.io client for Unity, power game client with node.js back-end
494 stars 75 forks source link

Constant Disconnect from socket.io #27

Closed VrTech closed 2 years ago

VrTech commented 6 years ago

image

Do you know why Unity keeps disconnect and connect to socket.io ? Thank you

enGMzizo commented 6 years ago

I found the same issue and it happens exactly every 30 seconds

Zbluu commented 6 years ago

I had the same issue. It was an error in one of my custom events, so my Unity client was automatically disconnected. Try to remove all your event listeners. And check also the pingTimeout and pingInterval on your server.

maginc commented 6 years ago

Same thing, it just keeps reconnecting even if everything is ok.

kodypeterson commented 6 years ago

I found that setting the pingInterval to 500 resolves this issue.

It looks like the Github project for the SocketIoClientDotNet test server does this as well https://github.com/Quobject/SocketIoClientDotNet/blob/f7e768793abfda7f4660d2f5b0260a325c0c2487/TestServer/server.js#L32

maginc commented 6 years ago

It's actually working! Thanks mate!

ltphy commented 6 years ago

Where can i set the pingInterval in my client (C#) script?

Zbluu commented 6 years ago

I think you can't, the pingInterval is defined by the server, not the client.

jimtendo commented 3 years ago

I was having a similar issue (different cause) and thought it might be worth posting here in case others stumble upon this.

I have a VueJS App that contained a link like so:

<a href="bitcoincash:qrks5vefcxzjrmadcn5e3vthkp65lh4npvd0gw3qcs">Pay</a>

Clicking this link would force my SocketIO client to disconnect (probably considered a "navigate away" by the Socket IO client library - suspect other URL schemes would behave the same).

To mitigate, just add target="_blank" to your hyperlink so that the hyperlink is opened in a new window (thus avoiding Socket IO considering this a "navigate away" action).

astechnolabs-fullstack commented 3 years ago

I found that setting the pingInterval to 500 resolves this issue.

It looks like the Github project for the SocketIoClientDotNet test server does this as well https://github.com/Quobject/SocketIoClientDotNet/blob/f7e768793abfda7f4660d2f5b0260a325c0c2487/TestServer/server.js#L32

not working. I tried this with my Node code, same issue...