HRC

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

HRC

Postby wallis2xk » 09 Jan 2013, 15:01

Hi, I'm trying to implement the HRC system in our Unity game and am currently testing this on Android. I am testing this against a issue with our router which will every so often reset its wifi connection.

Before this just resulted in an instant CONNECTION_LOST event, but with HRC turned on the following is happening:

Client-side the CONNECTION_RETRY event is fired instantly but after that neither CONNECTION_RESUME is fired nor is CONNECTION_LOST fired even after 10 minutes. (Idle disconnection is 120 seconds). Following is the adb logcat for Unity.

Image

Then on the server side this warning is the first thing that comes up

Code: Select all

09 Jan 2013 | 14:24:05,675 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController |     | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.212.67.17:9933 remote=/86.130.63.165:60129]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)

then five seconds later

Code: Select all

09 Jan 2013 | 14:24:09,233 | INFO  | pool-1-thread-2 | Extensions |     | {battleMonkeys}: UserReconnectTryEventHandler - user:dave


then after 20 seconds (what I have set the user reconnection timeframe to)

Code: Select all

09 Jan 2013 | 14:24:29,385 | INFO  | Scheduler1-thread-1 | v2.entities.SFSZone |     | User: dave was disconnected.
09 Jan 2013 | 14:24:29,388 | INFO  | Scheduler1-thread-1 | v2.api.SFSApi |     | User disconnected: { Zone: BattleMonkeys }, ( User Name: dave, Id: 0, Priv: 1, Sess: 86.130.63.165:45244 ) , SessionLen: 329935, Type: UnityPlayer::


Not sure if I should be doing something else or soemthing is broken? Should also say using killConnection() to test it everything seems to work properly and get called in the right order very quickly,

Thanks
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 08:17

Can you clarify which API/Server version are you using and what is the time settings for the reconnection?
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 08:52

I'm using latest versions, 2.5.0 server and 1.0.6 C# client.

The server-side time reconnection is set to 20 seconds. ( have also played with the client-side method of setReconnectionSeconds() but I can't find any docs on what effect this actually has)
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 09:11

Ok, thanks, we'll take a closer look.
( have also played with the client-side method of setReconnectionSeconds() but I can't find any docs on what effect this actually has)

Not a good idea, if you want to change it do it via the server configuration (AdminTool > ZoneConfigurator)
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 09:16

Thanks. Yes, that is what I was ultimately testing with in this example, 20 seconds server-side and nothing on the client-side.
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 10:11

Actually I am not able to reproduce the problem.
The way we test this is simple, we use two machines Server and Client.

> Client connects to server
> Server turns firewall ON
> Client causes abrupt disconnection by calling killConnection() method
> ... some time passes < max reconnection time ...
> Server turns firewall OFF
> Client is reconnected successfully

This is a simple test case scenario that mimics a situation in which the client network isn't immediately available.
Of course the variety of problems over the internet is much bigger and HRC cannot handle all of them. Cases in which a disconnection remains "pending" will probably take more time to reconnect or even fail completely.

In your specific case, however, it sounds like the disconnection is properly recognized by the API which should trigger the reconnection process.

Client-side the CONNECTION_RETRY event is fired instantly but after that neither CONNECTION_RESUME is fired nor is CONNECTION_LOST fired even after 10 minutes. (Idle disconnection is 120 seconds). Following is the adb logcat for Unity.

If the client is able to reconnect you should notice it in the server logs, you will find an entry. If that doesn't show up I think the client is unable to reach the server at all.
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 10:21

I understand that HRC can't solve every situation, but I was hoping it could solve this one as it might be a not uncommon issue of a router deciding to restart its wifi every ~30 minutes. But even if it can't, I would hope that a CONNECTION_LOST event would be called client-side after the timeout, but I'm not getting that.

In this case I believe the client side thinks it has reconnected as the adb logs stopped showing reconnection attempts after a few seconds, which is when the wifi seemingly came back up. The issue to me seems to be this message on the server side?

Code: Select all

09 Jan 2013 | 14:24:05,675 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController |     | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.212.67.17:9933 remote=/86.130.63.165:60129]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)


I'm guessing this is where something has gone wrong?
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 11:18

09 Jan 2013 | 14:24:05,675 | WARN | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController | | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.212.67.17:9933 remote=/86.130.63.165:60129]


The error is fired ad 14:24:05. At what time does the disconnection occur?
Can you show all the messages in the logs that show when the disconnection is detected and when this error is fired?

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 11:23

Think I put all the relevant logs in the first post, so this is the very first thing that comes up when the wifi resets

Code: Select all

09 Jan 2013 | 14:24:05,675 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController |     | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.212.67.17:9933 remote=/86.130.63.165:60129]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)


then about four seconds later the reconnection try event is fired

Code: Select all

09 Jan 2013 | 14:24:09,233 | INFO  | pool-1-thread-2 | Extensions |     | {battleMonkeys}: UserReconnectTryEventHandler - user:dave


then after 20 seconds the user is disconnected (20 seconds is what I have set the user reconnection timeframe to), but no event comes to the client.

Code: Select all

09 Jan 2013 | 14:24:29,385 | INFO  | Scheduler1-thread-1 | v2.entities.SFSZone |     | User: dave was disconnected.
09 Jan 2013 | 14:24:29,388 | INFO  | Scheduler1-thread-1 | v2.api.SFSApi |     | User disconnected: { Zone: BattleMonkeys }, ( User Name: dave, Id: 0, Priv: 1, Sess: 86.130.63.165:45244 ) , SessionLen: 329935, Type: UnityPlayer::
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 12:42

[quote="wallis2xk"]Think I put all the relevant logs in the first post, so this is the very first thing that comes up when the wifi resets

Code: Select all

09 Jan 2013 | 14:24:05,675 | WARN  | com.smartfoxserver.v2.controllers.SystemController-1 | v2.controllers.SystemController |     | com.smartfoxserver.bitswarm.exceptions.SessionReconnectionException: Session Reconnection failure. The passed Session is not managed by the ReconnectionManager: java.nio.channels.SocketChannel[connected local=/10.212.67.17:9933 remote=/86.130.63.165:60129]
   com.smartfoxserver.bitswarm.sessions.DefaultReconnectionManager.reconnectSession(DefaultReconnectionManager.java:137)
   com.smartfoxserver.bitswarm.sessions.DefaultSessionManager.reconnectSession(DefaultSessionManager.java:383)
   com.smartfoxserver.v2.controllers.system.Handshake.execute(Handshake.java:68)
   com.smartfoxserver.v2.controllers.SystemController.processRequest(SystemController.java:130)
   com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
   java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)


The first error is telling us that a client has attempted a reconnection but the Server is not even aware that this is going on.
Before this error is fired there should be a Session removed entry related to the same user.

What I think is happening is that when your router quits abruptly the client and server OS will not complete a proper TCP disconnection which is a 4 steps exchange. When this happens the client/server OS will maintain the connection open (probably in CLOSE_WAIT state) for a while and eventually the TCP timeout will fire finally causing a disconnection.

These mechanisms work below our API level, below the JVM and client runtime and even below the OS API, so there's no control over them.
If you know how TCP works and are equipped with the proper networking utilities (e.g. WireShark, netstat, etc...) you can take a look at what's going on at the low level, precisely.

In any case making assumptions in which scenarios it will or won't work is very hard because it depends on a very high number of variables.
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 12:56

Right, ok. Just trying to understand this a bit better - if there is this abrupt disconnection, what does the server know that causes it to trigger the 'Session Reconnection failure' and also the UserReconnectTryEventHandler on the server? Does this happen when it receives a signal from the client again?

Is there any debugging/further info I can get from netstats or other software that would help you?

Regardless of this it seems implementing HRC in this case actually makes things worse, as previously CONNECTION_LOST was fired instantly whereas now it's never fired, leaving the gameplay in limbo.
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 13:28

wallis2xk wrote:Right, ok. Just trying to understand this a bit better - if there is this abrupt disconnection, what does the server know that causes it to trigger the 'Session Reconnection failure' and also the UserReconnectTryEventHandler on the server? Does this happen when it receives a signal from the client again?

Yes, the error is caused by the fact that the client is asking to reconnect but the server is not aware that he has disconnected.
Why? There can be many possibilities. Try pulling your ethernet cable when you have one or more clients connected to a server (e.g. FTP) and instead of seeing disconnection errors nothing will happen :)
As I said the TCP disconnection is actually a 4-way exchange between client and server. Pulling the cord all of a sudden shuts down any forms of communication therefore the aforementioned 4-way disconnection exchange will never happen. The TCP stack has his own ways of monitoring idle connections and it will eventually remove them after a while.

Is there any debugging/further info I can get from netstats or other software that would help you?

The extra digging into the low level protocol might be interesting but won't solve the problem. Neither the server nor the client can access that level of the OS.

Regardless of this it seems implementing HRC in this case actually makes things worse, as previously CONNECTION_LOST was fired instantly whereas now it's never fired, leaving the gameplay in limbo.

It's actually the same thing because the server doesn't know about the client disconnection.
Also, as I said before, making assumptions on how it will work with another client is not possible due to the many variables and cases.
One thing you can do is collecting feedback from users and seeing how it is working for them.
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 13:38

Yes, the error is caused by the fact that the client is asking to reconnect but the server is not aware that he has disconnected.


If the client is disconnected though (wifi has just gone down) how is it telling the server it wants to reconnect?

I guess the bottom line is that from the docs I believe that on the client-side it should trigger either reconnection success event or connection lost event? Neither of these are happening.

We do have some users who do complain about connection lost cropping up randomly. As you say this could be for lots of reasons but if the HRC can help with some of these that'd be great. But from the one real situation I'm able to test on it doesn't seem to be helping.
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC

Postby Lapo » 10 Jan 2013, 14:37

If the client is disconnected though (wifi has just gone down) how is it telling the server it wants to reconnect?

This is something you should investigate. The logs is telling you precisely at which moment this request is happening. Evidently the wireless is up and running. Check with a tool such as Wireshark on your client to see exactly what is going on.

If you can provide more details we can try to help you to understand what is going on.
Lapo

--

gotoAndPlay()

...addicted to flash games
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Re: HRC

Postby wallis2xk » 10 Jan 2013, 15:49

Right, don't know if this is the right stuff that you're looking for but this is what Wireshark seems to be outputting when it happens

Image
Image

Also here is full adb logcat if it is of any use

Image
Image
Image

:)

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 4 guests