List of user's that are dropping packets

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

List of user's that are dropping packets

Postby mmilen » 20 Mar 2021, 18:42

Hi,

Is there any way to quickly find out which user is dropping packets? I can see sometimes how 10-15 packets are being dropped every 1-2 seconds. I need to see which user is responsible for it.

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

Re: List of user's that are dropping packets

Postby Lapo » 22 Mar 2021, 08:28

Hi,
what version of SFS2X are you currently using?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 22 Mar 2021, 14:25

version 2.16.1
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: List of user's that are dropping packets

Postby Lapo » 23 Mar 2021, 09:08

You could add a listener for an internal event called BitSwarmEvent.PACKET_DROPPED.
Generally speaking this is not a good idea in production because dropped packet events can be generated in the thousands per second and running custom listeners can become performance intensive.

In any case this is a quick example. This is what a listener could look like:

Code: Select all

import package com.smartfoxserver.bitswarm.events.*;

public class MyListener implements IEventListener
{
   @Override
   void handleEvent(IEvent event)
   {
      ISession session = (ISession) event.getParameter("session");
      User user = SmartFoxServer.getInstance().getUserManager().getUserBySession(session);

   }
}


And this is to attach the event listener in your Extension init() method:

Code: Select all

@Override
public void init()
{
   BaseCoreService sw = (BaseCoreService) BitSwarmEngine.getInstance().getSocketWriter();
   sw.addEventListener(BitSwarmEvents.PACKET_DROPPED, new MyListener());
}


NOTE:
Starting from SFS2X 2.16.3 and higher this event is no longer triggered by default.
Here's the release note extract:

    [NEW] By default Bitswarm events BitSwarmEvents.PACKET_DROPPED are no longer triggered, as they are rarely utilized and can use up performance in high traffic servers with lots of outgoing packet loss. Developers can manually enable the event via config/core.xml by adding the following: <triggerDroppedPacketEvents>true</triggerDroppedPacketEvents>.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 23 Mar 2021, 14:11

Thanks.
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 23 Mar 2021, 14:13

How can I add this to Admin?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: List of user's that are dropping packets

Postby Lapo » 23 Mar 2021, 17:53

It can't be added to the Admin, sorry. This is a low level event listener that you can add to your Extension code if you want to see which connections are dropping.

Honestly though, I am not sure how this can help since packet dropping is not something you can correct. It typically depends on the client's connection and there's not much you can do. The server already handles the situation automatically to the best of its ability (which depends on the client's network in the end).

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 23 Mar 2021, 19:32

Thanks. Will give it a tray int he extension and see how it impacts.
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 23 Sep 2021, 04:23

I'm in real trouble here. we use SFS for an educational product ( student and teachers ). Teachers monitor sometimes a couple of hundred students playing bridge and provide robot moves when needed. So a lot of data goes out to the teachers. However, somewhere in our code, there is a bug that comes up rarely and we can't trace it. The only symptom is we start to see a lot of dropped packets and need a way to figure out which teacher is dropping them without too much of a performance hit.

Any chance you can add some utility that fires an event if say 1000 packets are dropped per second by a session. All we need is the username for that session.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: List of user's that are dropping packets

Postby Lapo » 23 Sep 2021, 08:06

Hi,
every User's Session object has a dropped packet counter. So you can go through the list of teachers, check their packet-drop count and see which User has the highest values.

Example:

Code: Select all

int packetDropCount = user.getSession().getDroppedMessages();


Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: List of user's that are dropping packets

Postby mmilen » 23 Sep 2021, 10:23

Thank you. That is perfect.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 54 guests