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

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 » 04 Sep 2017, 13:48

The debug messages are displayed in the browser's JavaScript console.
Also include the INFO, WARN and ERROR levels.

This code shows an example of configuration:

Code: Select all

sfs.AddLogListener(LogLevel.DEBUG, OnDebugMessage);
sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);
         
// Set connection parameters
ConfigData cfg = new ConfigData();
cfg.Host = ...
cfg.Port = ...
cfg.Zone = ...
cfg.Debug = True;

In those log listeners use the Debug.Log(string) method provided by Unity.
Paolo Bax
The SmartFoxServer Team
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 04 Sep 2017, 13:59

I've retested with the Debug set to True on the ConfigData, and nothing new has surfaced. I've got the same message back with the error (SFS: [SFS > ERROR] [WebSocketLayer] Communication error: Abnormal disconnection.) and no extra messages along side it.
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 » 04 Sep 2017, 14:03

Would you be able to provide a test project showing the issue?
That would be very useful as we can't reproduce it.
Paolo Bax
The SmartFoxServer Team
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 04 Sep 2017, 14:04

Thanks Bax for the information, but i did the exact thing and the callback for LogLevel.DEBUG isnt firing. I used the exact same logs listeners from the example.
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 04 Sep 2017, 14:56

Yes i will be providing a test project, but it's going to take some preparation. Also you will be conducting your tests on our development environment, because the game requires a DB to function, i will send all the required server side, client side projects, IPs and credentials to Lapo via a private message tomorrow.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby Lapo » 04 Sep 2017, 15:32

Even better if you could send the data to our support@... email box.
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 05 Sep 2017, 12:15

I have sent the test project at support at smartfoxserver dot com
please confirm you have received it.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby Lapo » 05 Sep 2017, 14:19

Email received, thanks.
We'll get back to you asap.
Lapo

--

gotoAndPlay()

...addicted to flash games
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 08 Sep 2017, 14:23

Hello,

Wanted to do a follow up on this topic, since i've done some more tests and wanted to share results, maybe you could have some pointers.

Setup:
Client Api version: 2.13
Server version: 2.13


Case 1:
Player 1 joins room, Player 2 joins room, TaskScheduler starts, StartGame message is sent. All fine here.
Game Ends, Players still in room, TaskScheduler cancelled, TaskScheduler started again, StartGame message sent, WebGL clients get dropped.
Unity console doesnt trace the receiving of the StartGame Message, it displays:

Code: Select all

 [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

SmartfoxServer logs:
2017-09-08_1650.png
(154.01 KiB) Not downloaded yet


Case 2
Is similar to Case 1, the only difference is on the server side code. When the Game ends, I Send the StartGame message first, then Cancel the TaskScheduler, and Start it again. This doesn't drop the WegGL clients.

Case 3:
When leaving a room, the server updates the room's occupation numbers (like say, if 2 users are in 1 room, a 3rd user in the lobby would see that that room has 2 players in it, if a player leaves that room, the 3rd player would receive a RoomUpdate message with the number of remaining players for the room he left. This goes for every other room opened).

Knowing this the following happens. I have 2 Clients in 1 room, a Android Client and a WebGL client.
If both leave at the same time or leave in any order, if the webgl's lobby scene hasnt loaded completely yet, it will get disconnected after receiving the the RoomUpdate message, while sending the next PING_PONG messages back and forth i believe, with the following unity log:

Code: Select all

[SFS > ERROR] [WebSocketLayer]Communication error: An error has occurred in sending the data


If the WebGL leaves first and the lobby scene is fully loaded, then the android leaves, the webgl client remains connected and receives the RoomUpdate and updates correctly with the number of players in that room, and no errors are thrown.

SmartfoxServer log:
2017-09-08_1657.png
(120.21 KiB) Not downloaded yet


This would point out to a client api problem, the thing is, I've tested the above cases on server version 2.12, and none of them have the same results as on server version 2.13.
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, 07:13

What client API version are you using? (previously you wrote 2.13, but that's not the API numbering)
Also, does the issue occurs in the Unity Editor in WebGL mode only, or in the browser too, after building the project for WebGL?
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, 08:36

Sorry, you were right, i wrote down the wrong api version.

The api version that i am using in the tests is 1.7.4.

I have seen that you updated the api to 1.7.5, i will test it out to see if the behavior has changed.

Also this behavior occurs in the browser aswel.
fishbrainz
Posts: 20
Joined: 30 Aug 2017, 08:30

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby fishbrainz » 11 Sep 2017, 09:42

Client Api version 1.7.5 has the same behavior in those tests like 1.7.4. So nothing's changed.
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, 12:53

We are still investigating, but it seems the error occurs at a very low level of the WebSocket.

Can you please clarify why, in both screenshots you sent, the outgoing message is duplicate?
Also, could you send the text version of that log?

One more thing.. did you try to change the start message, for example sending an empty message? We would like to understand if the socket error is caused by the content of the message.
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, 13:28

Yes i have sent an empty message and the disconnects still happen. The Andorid client receives the empty message.

The messages are for android and webgl clients:

Android -

Code: Select all

binary.binaryToHandler

WebGL -

Code: Select all

jetty.WebSocketBinaryProtocolCodec


They are sent for each client connected to the server.

Txt smartfox log:
http://jab.ro/4eaf01861a67a23457673a2be22fb90e

(I can't seem to be able to attach .txt files to the post)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity WebGL - SFS 2.13 - WebSockets disconnect

Postby Lapo » 11 Sep 2017, 13:37

We saw the logs, thanks
Since the file is over 10K lines long can you tell me where is the "killer" message located? I am referring to the message shown in the previous screenshot (2017-09-08_1650.png)

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 40 guests