I'm using SFS2X for a turn based multiplayer game in Unity. I notice that the client times out after a certain time (probably 60 seconds default zone setting).
I assume the client library doesn't do any keepalive so I implemented my own thing to send a "Ping" message to the server once in a while. This ping message doesn't have any functionality other than as a keepalive.
On the server, I see this in the log every time in pings.
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Request handler not found: 'Ping'. Make sure the handler is registered in your extension using addRequestHandler()
Question is, is there any way to get rid of this error in the log other than to attach a request listener for the message? It seems wasteful on the server side to instantiate an object to handle this message that is just empty and doesn't do anything.
Ping to keep alive
Re: Ping to keep alive
Hi,
the default Zone setting is usually 300 seconds (5 minutes). However clients can loose their connection if they haven't sent a request in a while, due to all sorts of timeouts triggering on any of the devices between client and server (routers, gateways etc...)
What you have done is correct, but you will necessarily need an handler on the server side to deal with the message otherwise the error will continue to pop up.
True but, in the grand scheme of things, the resources wasted for something like this are infinitesimally small
Really nothing to worry about. If you want to exceed on the optimization side of things you can mark the request handler with the @Instantiation(SINGLE_INSTANCE) annotation. This will create the handler once and reuse it every time, avoiding new instantiations.
The annotation is discussed under the Advanced Extension concepts in this article:
http://docs2x.smartfoxserver.com/Extens ... a/overview
Also, keep in mind: If you're using SFS2X 2.18.2 or higher there's no need for the above. From that release we have introduced an option in the client LagMonitor that allows to keep the connection alive, while also checking the current lag. Two birds one stone
Release notes can be found here:
https://www.smartfoxserver.com/download ... X_2.18.txt
Hope it helps
the default Zone setting is usually 300 seconds (5 minutes). However clients can loose their connection if they haven't sent a request in a while, due to all sorts of timeouts triggering on any of the devices between client and server (routers, gateways etc...)
What you have done is correct, but you will necessarily need an handler on the server side to deal with the message otherwise the error will continue to pop up.
It seems wasteful on the server side to instantiate an object to handle this message that is just empty and doesn't do anything.
True but, in the grand scheme of things, the resources wasted for something like this are infinitesimally small
Really nothing to worry about. If you want to exceed on the optimization side of things you can mark the request handler with the @Instantiation(SINGLE_INSTANCE) annotation. This will create the handler once and reuse it every time, avoiding new instantiations.
The annotation is discussed under the Advanced Extension concepts in this article:
http://docs2x.smartfoxserver.com/Extens ... a/overview
Also, keep in mind: If you're using SFS2X 2.18.2 or higher there's no need for the above. From that release we have introduced an option in the client LagMonitor that allows to keep the connection alive, while also checking the current lag. Two birds one stone
Release notes can be found here:
https://www.smartfoxserver.com/download ... X_2.18.txt
Hope it helps
-
- Posts: 4
- Joined: 21 Oct 2022, 07:22
Re: Ping to keep alive
The server expects the BlueBox-based client to poll every X seconds to check for new events. When the server realizes that the client hasn't showed up for some time asking for news it will consider him/her disconnected.
The amount of time for this to happen is usually around 30-40 seconds.
we are using older version than this using SFS2X 2.18.2
what is correct way to implement every X seconds to check for new events ?
Also when player is moving then what happened ?
The amount of time for this to happen is usually around 30-40 seconds.
we are using older version than this using SFS2X 2.18.2
what is correct way to implement every X seconds to check for new events ?
Also when player is moving then what happened ?
Re: Ping to keep alive
piyush1234567 wrote:The server expects the BlueBox-based client to poll every X seconds to check for new events. When the server realizes that the client hasn't showed up for some time asking for news it will consider him/her disconnected.
The amount of time for this to happen is usually around 30-40 seconds.
we are using older version than this using SFS2X 2.18.2
what is correct way to implement every X seconds to check for new events ?
The BlueBox is more sophisticated than that. It's not just a polling-based mechanism, it uses server-side continuations to get real-time updates. For more details, see here: http://docs2x.smartfoxserver.com/GettingStarted/bluebox
You don't have to check any events. Events are triggered as soon as they are received by the client side API. In other words: regardless of your connection type, the client API always work in the same way.
Also when player is moving then what happened ?
It depends on what your application does. If you're sending updates when a player moves the other players will receive the relative update.
The bottom line is: you don't have to code differently for BlueBox clients, they are just simply connected via a different channel but from a developer's perspective nothing changes.
Cheers
Who is online
Users browsing this forum: No registered users and 118 guests