Hello,
I'm having a very weird issue with Unity WebGL and SFS 2.13.
I have a android client and a unity webgl client connected to the same room (Game Room). And another WebGl Client connected to the lobby (a separate room).
When a 2nd player is connected to the Game Room, a ScheduleFuture task is started with a periodic tick of 1 second with the help of a TaskScheduler through scheduleAtFixedRate() to countdown the time each player has available to do his actions. After this I send 1 start game message to each of the clients, signaling the game start.
After the match is over, if there are still 2 or more players connected, i try to start another match. If there is A SchedulerFuture task in the loop, from a previous game, i do a .cancel() and start another ScheduleFuture task like mentioned above, and then i send the game start message.
The problem occurs right here: when sending this second game start message after a match has been played. All WebGL clients that are connected to that room when the second start game message is sent are instantly disconnected.
Testing stuff out, i noticed that if i dont cancel() the ScheduleFuture task, the clients are not disconnected, but that causes some unwanted countdowntimer glitches within my room's logic.
I used a remote debug connection with jetty, and set up breakpoints to further identify the cause, stepping into and over code in multiple attempts . Sadly i could only so far down the rabbit hole. I managed to identify line 97 from "com.smartfoxserver.bitswarm.websocket.jetty" as being the line when the webGL clients are dropped right at the "channel.write(rawPacket);" line.
Help?
Thanks
Fish.
Unity WebGL - SFS 2.13 - WebSockets disconnect
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
Hi,
two questions:
1- can it reproduced every time?
2- does it happen locally?
thanks
two questions:
1- can it reproduced every time?
2- does it happen locally?
thanks
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
1. Yes i can be reproduced everytime.
2. I haven't tested it with a local sfs server. I will try to set one up and test it.
Thanks
fish.
2. I haven't tested it with a local sfs server. I will try to set one up and test it.
Thanks
fish.
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
After the match is over, if there are still 2 or more players connected, i try to start another match. If there is A SchedulerFuture task in the loop, from a previous game, i do a .cancel() and start another ScheduleFuture task like mentioned above, and then i send the game start message.
The problem occurs right here: when sending this second game start message after a match has been played. All WebGL clients that are connected to that room when the second start game message is sent are instantly disconnected.
Is the "start message" sent from the new scheduled Task or is it sent in the Extension handler?
Are there any errors on the server and client side when the disconnection occurs?
thanks
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
The start message is sent from the extension handler (i think, i dont know how exactly to check), the message is sent form our extension.jar
The server doesnt record any errors, it just prints the removal of the Webgl client and terminates its session.
The server doesnt record any errors, it just prints the removal of the Webgl client and terminates its session.
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
So if I understand correctly, you're saying that this "start message" is the cause of disconnection.
However I find it particularly odd because I suppose the same message is used the first time to start the game, right?
I cannot think of a single reason why a message sent from server side should kick everyone out, unless maybe the message was huge in size (e.g. MBytes of data)
My suggestion is to see if the problem can be reproduced in a local setup.
Thanks
However I find it particularly odd because I suppose the same message is used the first time to start the game, right?
I cannot think of a single reason why a message sent from server side should kick everyone out, unless maybe the message was huge in size (e.g. MBytes of data)
My suggestion is to see if the problem can be reproduced in a local setup.
Thanks
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
Yes, I agree with your that its odd, for the same reason, the same start message is sent first time around.
I will try to reproduce it locally. Will come back with the results.
Thanks
fish.
I will try to reproduce it locally. Will come back with the results.
Thanks
fish.
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
Side note: It doesnt kick everyone out, just the WebGL clients, Android clients remain connected.
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
fishbrainz wrote:Side note: It doesnt kick everyone out, just the WebGL clients, Android clients remain connected.
Gotcha. Have you also checked the browser's console when the disconnection happens? To see if there's any detail or error?
I don't think there will any major clue but it still might help to keep an eye on that.
cheers
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
I usually test it with 1 browser WebGL client and the Unity Editor set to WebGL platform and both get bet disconnected. SFS Errors listed below.
WebGL client throws
SFS: [SFS > ERROR] [WebSocketLayer] Communication error: Abnormal disconnection.
Unity Editor on WebGL platform throws:
[SFS > ERROR] [WebSocketLayer] Communication error: An exception has occurred while receiving a message. at WebSocketSharp.WebSocketFrame+<ReadAsync>c__AnonStorey1A.<>m__2E (System.Byte[] header) [0x00000] in <filename unknown>:0
at WebSocketSharp.Ext+<ReadBytesAsync>c__AnonStoreyD.<>m__1D (IAsyncResult ar) [0x00000] in <filename unknown>:0
WebGL client throws
SFS: [SFS > ERROR] [WebSocketLayer] Communication error: Abnormal disconnection.
Unity Editor on WebGL platform throws:
[SFS > ERROR] [WebSocketLayer] Communication error: An exception has occurred while receiving a message. at WebSocketSharp.WebSocketFrame+<ReadAsync>c__AnonStorey1A.<>m__2E (System.Byte[] header) [0x00000] in <filename unknown>:0
at WebSocketSharp.Ext+<ReadBytesAsync>c__AnonStoreyD.<>m__1D (IAsyncResult ar) [0x00000] in <filename unknown>:0
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
Thanks.
It would probably be helpful to activate the Debug mode in the SFS API, so that the whole transmission between client and server is captured.
Can you do that and show us the debug?
The parameter is found in the ConfigData object that you pass to Connect() method.
Cheers
It would probably be helpful to activate the Debug mode in the SFS API, so that the whole transmission between client and server is captured.
Can you do that and show us the debug?
The parameter is found in the ConfigData object that you pass to Connect() method.
Cheers
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
The Debug property was set to true, but no additional information was being sent, the only extra information received was through the LogLevel.Info's listener callback, but nothing of value, just the binary stuff. The LogLevel.DEBUG listener was also set but wasnt firing at all.
Do i have to set the sfs server's, and extension's, log4.properties to DEBUG aswel for it the client LogLevel.DEBUG's listener to receive data?
Do i have to set the sfs server's, and extension's, log4.properties to DEBUG aswel for it the client LogLevel.DEBUG's listener to receive data?
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
I have tried to get the DEBUG data but i can't seem to figure it out how.
Config.Debug = true
Sfs has the LogLevel.DEBUG listener set with its callback but nothing is firing.
Serverside log4.properties are set to DEBUG
Still, nothing on the client side is receiving extra debug data.
Config.Debug = true
Sfs has the LogLevel.DEBUG listener set with its callback but nothing is firing.
Serverside log4.properties are set to DEBUG
Still, nothing on the client side is receiving extra debug data.
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
It's not that the client will receive extra debug data. You should find the messages exchanged with the server logged in the browser's console.
-
- Posts: 20
- Joined: 30 Aug 2017, 08:30
Re: Unity WebGL - SFS 2.13 - WebSockets disconnect
Should i see these messages in the console log of unity also?
EDIT: ... if unity is set for the webgl platform, seeing that the editor is being disconnected also?
EDIT: ... if unity is set for the webgl platform, seeing that the editor is being disconnected also?
Who is online
Users browsing this forum: No registered users and 74 guests