question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sending a message then closing program does not flush message.

See original GitHub issue

So, calling NetClient.Disconnect("Message"); and then closing the application by exiting the Main function does not seem to send the disconnect message to the server and instead the connection closes by timing out.

NetClient.FlushSendQueue() does not seem to do anything just after Disconnect either.

My workaround was

while ((Peer as NetClient)?.ServerConnection != null)
        Thread.Sleep(10);

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
RevoluPoweredcommented, Feb 23, 2018

Found out the source of the issue, so what’s happening is, NetServer’s socket is getting cleaned up properly the first time it closes down / kind-of, then the NetClient properly disconnects.

If that same client reconnects to the server, even a new instance of it, the socket doesn’t close. When the server closes for the second time, the client has to timeout.

I think the issue is in the NetClient, and I’ll see if i can fix it for tomorrrow.

note it also doesn’t seem to be happening all of the time.

1reaction
sbarisiccommented, Feb 22, 2018

ckmcgk

Lidgren_Test.zip

Here’s the result and the whole project. Tested with start NetTest.exe --server && start cmd /C "NetTest.exe && pause"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using flush() before close() - java
Developer get into a habit of calling flush() after writing something which must be sent. IMHO Using flush() then close() is common when ......
Read more >
Solved: Flush Channel Messages - NI Community
Solved: I'm using the Channeled Message Handler (CMH) template for an application. I have one of my parallel While loops (call it "Loop...
Read more >
M_FLUSH Message Handling - STREAMS Programming ...
The stream head does not flush the write queue (no messages will be queued there). The stream head turns the message around (sends...
Read more >
Documentation: 15: 55.2. Message Flow
The Flush message does not cause any specific output to be generated, but forces the backend to deliver any data pending in its...
Read more >
Logging handlers — Python 3.11.4 documentation
Flushes the stream by calling its flush() method. Note that the close() method is inherited from Handler and so does no output, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found