Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 01 Feb 2017, 07:24

Hi,

I am having below mentioned issues while using the html5 client api.

-- If logged in at sfs and not joined any game room within a zone and got disconnected then we got the above event at the html5 client after the configured time (i.e. recconnection + Idle time as configured at the zone level).

-- If logged in at sfs and joined any game room within a zone and got disconnected then we didn't got the above event at the html5 client. Due to which our client got irresponsive after some time.

At server end, the above event is generated successfully in both the above mentioned schenerios.

So, Could you please let me know; what we are missing or How can we handle the disconnection in the above schenerio at the client end.


Regards,
Vipin Kumar
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Bax » 01 Feb 2017, 07:59

We tested your scenario and we couldn't reproduce the issue.
Can you please test with one of the examples we distribute? Specifically with the Advanced Chat one.
You can connect and login without joining a Room, or create a Game Room and join it.
When the idle time is reached, the user is disconnected as expected.
Maybe in your code you are removing the listener somewhere?
Paolo Bax
The SmartFoxServer Team
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 10 Feb 2017, 10:51

Hi Paolo,

I tried to test your application (i.e. Advanced Chat) and found that the disconnect event are generated on time within the same after disconnection.

But after comparing it with my application the main difference is that
- In your application the given data is sent to the server after every 5 seconds.
(whether we are in lobby room or in any of the custom rooms.)
{"a":29,"c":0,"p":{}} 21 14:15:21.046
{"p":{},"a":29,"c":0} 21 14:15:21.049
{"a":29,"c":0,"p":{}} 21 14:15:26.048
{"p":{},"a":29,"c":0} 21 14:15:26.050


- In our client application we used to send the custom data after every 5 seconds when we are in the lobby room.
(in which case we used to get the disconnect event on time after actual disconnection)
But when we joined any of the custom game room we stop sending any such custom data to the server after fixed interval.
we only send the data which is required by the game/user. if no action taken at client end then we wont send any data.
(in which case we won't get any disconnect event after actual disconnection and the client becomes unresponsive)

So, My question is that
Is it necessary to sent such data packet to the server after fixed interval all the time in order get the events on time?
If it is so then please let us know why?


Regards
Vipin
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Bax » 10 Feb 2017, 14:17

That's just the API internal lag monitor. You can easily turn it off in the example code (remove the sfs.enableLagMonitor call).
That should make no difference at all. Can you please retest after disabling it?
Thanks.
Paolo Bax
The SmartFoxServer Team
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 13 Feb 2017, 07:59

Hi Paolo,

I tried to test the given scenerio with your application (i.e. after removing the sfs.enableLagMonitor call from the Advanced Chat application) . FYI, your application is also becomes unresponsive and we won't get the given event on time.

So, should we consider that we need to send the continous data from client in order to get the events on time??

Regards
Vipin
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Bax » 13 Feb 2017, 09:11

I don't think so. Let me investigate more. I'll let you know soon.
Paolo Bax
The SmartFoxServer Team
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 13 Feb 2017, 10:10

okk, I will wait for your response.

Regards,
Vipin
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Bax » 13 Feb 2017, 14:41

This is quite strange, because I still can't reproduce the issue.
In the Advanced Chat example I disabled the lag monitoring. Started the application, logged in and joined the Lobby Room.
After the configured max idle time (30 seconds), my client got disconnected and I received the expected event.

This is the server log:

Code: Select all

15:41:00,836 INFO  [New I/O worker #1] sessions.DefaultSessionManager     - Session created: { Id: 1, Type: WEBSOCKET, Logged: No, IP: 127.0.0.1 } on Server port: 8888 <---> 51979
15:41:05,596 INFO  [SFSWorker:Sys:4] api.SFSApi     - User login: { Zone: BasicExamples }, ( User Name: bax, Id: 0, Priv: 0, Sess: 127.0.0.1:51979 ) , Type: JavaScript
15:41:09,493 INFO  [SFSWorker:Sys:2] api.SFSApi     - Room joined: [ Room: The Lobby, Id: 0, Group: default, isGame: false ], { Zone: BasicExamples }, ( User Name: bax, Id: 0, Priv: 0, Sess: 127.0.0.1:51979 ) , asSpect: false
15:41:49,423 INFO  [New I/O worker #1] sessions.DefaultSessionManager     - Session removed: { Id: 1, Type: WEBSOCKET, Logged: Yes, IP: 127.0.0.1:51979 }
15:41:49,425 INFO  [SFSWorker:Sys:4] api.SFSApi     - User disconnected: { Zone: BasicExamples }, ( User Name: bax, Id: 0, Priv: 0, Sess: 127.0.0.1:51979 ) , SessionLen: 43828, Type: JavaScript


And this is the client log:

Code: Select all

[Log] [INFO] OUTGOING DATA (SFS2X_API_JS.js, line 175)
p: [Object]
   cl: JavaScript (Str)
   api: 1.2.1 (Str)
c: 0 (Num)
a: 0 (Num)

[Log] [INFO] OUT > Handshake (SFS2X_API_JS.js, line 175)
[Log] {"a":0,"c":0,"p":{"api":"1.2.1","cl":"JavaScript"}} (SFS2X_API_JS.js, line 304)
[Log] [INFO] INCOMING DATA (SFS2X_API_JS.js, line 175)
c: 0 (Num)
a: 0 (Num)
p: [Object]
   tk: f865a5d6b686a1596be24ec2ff440f84 (Str)
   ms: 500000 (Num)
   ct: 1024 (Num)

[Log] [INFO] IN < Handshake (SFS2X_API_JS.js, line 175)
[Log] Connected to SmartFoxServer 2X! (main.js, line 680)
[Log] Session id: f865a5d6b686a1596be24ec2ff440f84 (main.js, line 680)
[Log] [INFO] OUTGOING DATA (SFS2X_API_JS.js, line 175)
p: [Object]
   pw:  (Str)
   un: bax (Str)
   zn: BasicExamples (Str)
c: 0 (Num)
a: 1 (Num)

[Log] [INFO] OUT > Login (SFS2X_API_JS.js, line 175)
[Log] {"a":1,"c":0,"p":{"zn":"BasicExamples","un":"bax","pw":""}} (SFS2X_API_JS.js, line 304)
[Log] [INFO] INCOMING DATA (SFS2X_API_JS.js, line 175)
c: 0 (Num)
a: 1 (Num)
p: [Object]
   id: 0 (Num)
   rl: [Array]
      0: [Array]
         8: [Array]
         7: 150 (Num)
         6: 0 (Num)
         5: false (Bool)
         4: false (Bool)
         3: false (Bool)
         2: default (Str)
         1: The Lobby (Str)
         0: 0 (Num)
   pi: 0 (Num)
   un: bax (Str)
   zn: BasicExamples (Str)
   rs: 0 (Num)

[Log] [INFO] IN < Login (SFS2X_API_JS.js, line 175)
[Log] Login successful! (main.js, line 680)
   Zone: BasicExamples
   User: [User: bax, Id: 0, Is me: true]
   Data: undefined
[Log] [INFO] OUTGOING DATA (SFS2X_API_JS.js, line 175)
p: [Object]
   i: 0 (Num)
c: 0 (Num)
a: 4 (Num)

[Log] [INFO] OUT > JoinRoom (SFS2X_API_JS.js, line 175)
[Log] {"a":4,"c":0,"p":{"i":0}} (SFS2X_API_JS.js, line 304)
[Log] [INFO] INCOMING DATA (SFS2X_API_JS.js, line 175)
c: 0 (Num)
a: 4 (Num)
p: [Object]
   ul: [Array]
      0: [Array]
         4: [Array]
         3: 0 (Num)
         2: 0 (Num)
         1: bax (Str)
         0: 0 (Num)
   r: [Array]
      8: [Array]
      7: 150 (Num)
      6: 1 (Num)
      5: false (Bool)
      4: false (Bool)
      3: false (Bool)
      2: default (Str)
      1: The Lobby (Str)
      0: 0 (Num)

[Log] [INFO] IN < JoinRoom (SFS2X_API_JS.js, line 175)
[Log] Room joined: [Room: The Lobby, Id: 0, Group id: default] (main.js, line 680)
[Log] [INFO] INCOMING DATA (SFS2X_API_JS.js, line 175)
c: 0 (Num)
a: 1001 (Num)
p: [Object]
   uc: 1 (Num)
   r: 0 (Num)

[Log] [INFO] IN < UserCountChange (SFS2X_API_JS.js, line 175)
[Log] [INFO] INCOMING DATA (SFS2X_API_JS.js, line 175)
c: 0 (Num)
a: 1005 (Num)
p: [Object]
   dr: 0 (Num)

[Log] [INFO] IN < ClientDisconnection (SFS2X_API_JS.js, line 175)
[Log] I was disconnected; reason is: idle (main.js, line 680)
Paolo Bax
The SmartFoxServer Team
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 14 Feb 2017, 03:39

Hi,

Did you test the given scenario after actual disconnection???

Basically there are two scenarios
- client is connected to the internet before and after login and if we don't  send any data from client; the client got disconnected event after idle time.

- client is connected to the Internet before login and it got disconnected from the Internet after login; now if we don't try to send any data from client then we don't get any disconnected event after idle time and the client becomes unresponsive.


Regards
Vipin
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Lapo » 14 Feb 2017, 08:40

vipin.kumar wrote:- client is connected to the Internet before login and it got disconnected from the Internet after login; now if we don't try to send any data from client then we don't get any disconnected event after idle time and the client becomes unresponsive.

For starters this is contradictory. You're saying that you disconnect right after login but then you're saying that you need to send more data to get disconnected... :? :D

This can't be. You either disconnected right after login (and you received a disconnection event) or you did not.

I suspect that what you're saying is that you're trying to disconnect by maybe shutting down the wifi or pulling the ethernet cable, but this will not cause a disconnection. In fact if you check the state of your connections via netstat (available on linux, windows and macos) you will see that your connections are perfectly alive.

Shutting down the network doesn't cause a disconnection, because a disconnection requires several messages to be exchanged and this is no longer possible. So the connection remains lingering until the OS TCP will deal with it, typically after a timeout.
Lapo
--
gotoAndPlay()
...addicted to flash games
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 14 Feb 2017, 09:13

Yes, I mean to say the disconnection by shutting down wifi / pulling the ethernet cable.

So, the actual disconnection depends on the OS TCP.

So, Could you please suggest what can be the best way to get the connection information at the client level within a fixed interval of time (i.e. whether it is connected to the server or not)? Is it possible to get using SFS client API's?

Regards
Vipin
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby Lapo » 14 Feb 2017, 09:55

vipin.kumar wrote:Yes, I mean to say the disconnection by shutting down wifi / pulling the ethernet cable.

So, the actual disconnection depends on the OS TCP.

Yes. There is no disconnection when you shut down the wifi. In fact if you turn it back on after a while all previous connections will keep working as if nothing had happened.

It's the OS the keeps track of every connection and it eventually declares them as "dead" if they haven't been active for a long time.

So, Could you please suggest what can be the best way to get the connection information at the client level within a fixed interval of time (i.e. whether it is connected to the server or not)? Is it possible to get using SFS client API's?

Sorry there's not much other information available: the connection is always active unless you receive a disconnection event.
Lapo

--

gotoAndPlay()

...addicted to flash games
vipin.kumar
Posts: 7
Joined: 01 Feb 2017, 06:07

Re: Issue at HTML5 JavaScript API event "SFSEvent.CONNECTION_LOST"

Postby vipin.kumar » 14 Feb 2017, 10:09

Thanks for all the above provided information. :)

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 1 guest