CONNECTION_LOST event isn't always fired for websockets

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

CONNECTION_LOST event isn't always fired for websockets

Postby Hassan Khallouf » 23 Jul 2018, 09:02

Hello everyone

We have a game using smartfox 2x server, latest server version and latest SDK version to this date
we build the game using Unity for Android, iOS and WebGL

we have a global listener to handle disconnections, it's being fired correctly on all platforms with one exception

when the same user logs in from another device or even a new browser tab the event isn't fired, and the browser stays unaware of the disconnection, the next time the user invokes any request to smart fox the browser console logs this line:
WebSocket is already in CLOSING or CLOSED state.


all other disconnections are working just fine, or at least what we have tested so far, disconnections due to inactivity for x seconds, kick, or manual disconnections, they all work and fire the event

Is this an expected behaviour? can we do anything about it? or this is unexpected and it's caused by something in our code?
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: CONNECTION_LOST event isn't always fired for websockets

Postby Hassan Khallouf » 23 Jul 2018, 10:07

Update:
after trying to debug the SDK code we were able to fire the event

Apparently, the status code for this kind of disconnection is 1000, which means a normal disconnection
but I guess the event should be fired regardless, because it's not about having an error or not

so what we did is the following, in the SFSWebSockets.jslib provided by SFS sdk for unity
we commented the following line:
Line 53 if (e.code != 1000)


and now the disconnection is fired properly, logging in from another browser tab fires the event

Can you please clarify if this is an intended behaviour or bug? because the event is fired regardless on other platforms
or there is something else to be done for WebGL builds?
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: CONNECTION_LOST event isn't always fired for websockets

Postby Bax » 24 Jul 2018, 07:44

Thank you for reporting. We need to investigate the issue. We will let you know as soon as possible.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: CONNECTION_LOST event isn't always fired for websockets

Postby Bax » 25 Jul 2018, 09:50

We confirm the issue. We just released an updated version of the API ( v1.7.8 ) containing the modified SFSWebSockets.jslib file.
Again, thank you for reporting.
Paolo Bax
The SmartFoxServer Team
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: CONNECTION_LOST event isn't always fired for websockets

Postby Hassan Khallouf » 26 Jul 2018, 10:40

you are welcome
and thanks for the fast patch :D

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 59 guests