Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disconnected TCPServer thread won't terminate
(04-17-2022, 02:37 AM)kbriggs Wrote: In the OnConnect event I read headers required to establish a valid websocket and I have ReadTimeout set to 10000 so it doesn't get stuck there from bots that are just probing the port. If I get valid headers I assign an object to AContext.Data, otherwise I just Exit and disconnect them in the OnExecute event.

Why are you waiting for the OnExecute event? You should disconnect them in the OnConnect event if the WebSocket handshake is not valid.

(04-17-2022, 02:37 AM)kbriggs Wrote: I use madExcept's NameThread command along to way to track the progress of the connection.

What is the point of doing that? First off, Indy threads are already named by Indy. But more importantly, having MadExcept name threads only makes sense if an error report is generated, and you shouldn't be getting an error just for disconnecting clients normally.

(04-17-2022, 02:37 AM)kbriggs Wrote: Notice I update the thread name right before disconnecting.  And they do disconnect because when I run TCPView on my server, no one is connected to me. But those rogue threads never terminate and they build up over time and never stop unless I take the game server offline.

Do you have thread pooling enabled on your server?

(04-17-2022, 02:37 AM)kbriggs Wrote: Most of those IPs are from Russia. Why are these threads not terminating after the disconnect?

There is no way to diagnose your problem with the limited information you have provided so far.

(04-17-2022, 02:37 AM)kbriggs Wrote: By the way, this is my OnDisconnect event, which should just Exit immediately for these rogue connections:

What do AdminSessionDisconnect() and PlayerSessionDisconnect() look like? If I had to guess, maybe they are causing deadlocks you are not diagnosing, which are then affecting the rogue threads from cleaning up correctly. For instance, if there is a thread that is holding a lock to the server's Contexts list, then other connection threads can't fully terminate when they try to remove themselves from that list after their OnDisconnect events exit.


Messages In This Thread
RE: Disconnected TCPServer thread won't terminate - by rlebeau - 04-18-2022, 04:13 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)