Unity WebGL - SFS 2.13 - WebSockets disconnect

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

Moderators: Lapo, Bax

fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 11 Sep 2017, 13:44

Yes... my bad... should have thought of that before posting...

An example of a disconnect happens at line 8362. Right before the "websocket.jetty.WebSocketbinaryProtocolCodec" start message.

Thanks
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby Bax » 11 Sep 2017, 14:38

I've noticed that you cancel the scheduled task like this:

Code: Select all

loop.cancel(true);

(in CRoom.cancelGame method)

Did you try not to halt the thread abruptly, passing false instead of true to the cancel method?
Paolo Bax
The SmartFoxServer Team
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 11 Sep 2017, 14:49

No i haven't tested it I'll make the change and test the use cases out.

The CRoom.cancelGame method isn't called in the case of the WebGL disconnects. The CRoom.startGame is called, at line 949 after

Code: Select all

if(getTotalUsers() > 1)
but i understand what you are saying.

The startGame method also uses the

Code: Select all

loop.cancel(true)
i will make the change sudgested and try again.

Thank you very much for taking the time to look into the code.

EDIT:
I just realized, you were talking about about the other case, where exiting both users at the same time would cause the webgl clients to get disconnected. Long day...
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby Bax » 11 Sep 2017, 14:57

I wasn't referring to a specific case, because it is very hard to follow what your Extension does.
In any case we are not sure of the consequences of stopping a thread abruptly. There's a chance that some garbage remains in Jetty (which takes care of websocket communication) and when you send the next message an error is caused.
Paolo Bax
The SmartFoxServer Team
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 11 Sep 2017, 15:44

That solved it.

Both the cases in which the WebGL clients were disconnected were solved just by passing false to loop.cancel(), on both Unity Editor and browser WebGL clients.

Thank you for all the help, I just can't believe I didn't catch the ideea to test this out, even after i read the tutorial on "How to schedule timed tasks in an Extension".

Again, thanks for all your help and time.

Fish.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 72 guests