Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Connecting to server is delayed if some previous clients do not shutdown by the right way #113

Closed
kienhg96 opened this issue Dec 21, 2023 · 25 comments
Assignees

Comments

@kienhg96
Copy link
Contributor

kienhg96 commented Dec 21, 2023

Hi,

I run the example (client.c & server.c) and found an issue about the cleanup of previous client sessions.

I modified client.c by commenting the line number 97: signal( SIGINT, interrupt_handler) to make client cannot cleanup,
After that, I built both client & server on Windows, then run the server.

I opened another console to execute client. I repeated opening client and pressing ctrl + C to terminate it.
After 3 - 4 times of doing like that, the client connected to server after a bit delayed.

It seems that recvfrom in (netcode.c:836) emits a lot of WASECONNRESET

@gafferongames
Copy link
Contributor

gafferongames commented Dec 21, 2023

Can still you reproduce this connection delay if you run a client on a different machine than the one doing the non-cleanup clients?

@gafferongames
Copy link
Contributor

Secondly, is your client.c still binding to port 0, eg. random client port number?

@kienhg96
Copy link
Contributor Author

  1. I run the client on a different machine (MacOS) and connect to server (Windows) and the problem's still there.
  2. Yes, I used the modified version of https://github.com/networkprotocol/netcode/blob/master/client.c by commenting line 97 signal( SIGINT, interrupt_handler );. The configuration of port is 0 and after starting client, the port will be generated randomly

@gafferongames
Copy link
Contributor

This result is very strange. Are the WASECONNRESET errors showing up on the clients or on the server?

@gafferongames
Copy link
Contributor

gafferongames commented Dec 21, 2023

Also, I mean can you reproduce the connection delay with clients running on one machine, and then connect a client from a second machine, to a server running on a third machine? (Sorry to be a pain!) I just want to be 100% sure this is something specific to the server, and not a direct consequence of the socket layer on the clients not having the socket cleaned up.

@kienhg96
Copy link
Contributor Author

kienhg96 commented Dec 21, 2023

I confirm that this issue still happens.

  1. I run server on the first PC (Windows)
  2. I run the client 1 on a Macbook, and I repeatly start & stop the client 1.
  3. I run the client 2 on a Mac Mini and the connection to server is delayed. Sometimes, client cannot connect to server:
client started on port 52916
client id is 116b51e88fa7df47
client connecting to server 192.168.137.1:40000 [1/1]
client connect failed. connection request timed out
client disconnected

@gafferongames
Copy link
Contributor

gafferongames commented Dec 21, 2023

OK. I will look into this. Can you please post logs from the clients that connect properly, the client that has the connection delay, the client that fails to connect, and the server -- all with netcode_log_level set to NETCODE_LOG_LEVEL_DEBUG

thanks!

@kienhg96
Copy link
Contributor Author

Failed case:

Client =>

client started on port 57447
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client received connection keep alive packet from server
^C => Run
client started on port 57448
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
^C => Run
client started on port 54203
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C => Run
client started on port 61792
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C => Run
client started on port 61793
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C => Run
client started on port 61794
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client connect failed. connect token expired
client disconnected
client changed state from 'sending connection request' to 'connect token expired'

==============
=> Server

reset encryption manager
server started with 64 client slots
server received connection request from 127.0.0.1:57447
server sent connection challenge packet
server received connection response from 127.0.0.1:57447
server accepted client 127.0.0.1:57447 0000000000000029 in slot 0
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection request from 127.0.0.1:57448
server sent connection challenge packet
server received connection response from 127.0.0.1:57448
server accepted client 127.0.0.1:57448 000000000000038a in slot 1
server received connection response from 127.0.0.1:57448
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:57448
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:57448
server ignored connection response. a client with this address is already connected
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired
ignored connection request packet. connect token expired

@kienhg96
Copy link
Contributor Author

Delay case:

=> Client

client started on port 63138
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client received connection keep alive packet from server
client changed state from 'sending connection response' to 'connected'
client connected to server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
^C => Run
client started on port 63139
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client received connection keep alive packet from server
client changed state from 'sending connection response' to 'connected'
client connected to server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
^C => Run
client started on port 50364
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client received connection keep alive packet from server
client changed state from 'sending connection response' to 'connected'
client connected to server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection keep alive packet from server
client received connection payload packet from server


=> Server

server listening on 127.0.0.1:7777
reset encryption manager
server started with 64 client slots
server received connection request from 127.0.0.1:63138
server sent connection challenge packet
server received connection response from 127.0.0.1:63138
server accepted client 127.0.0.1:63138 0000000000000155 in slot 0
server received connection payload packet from client 0
server confirmed connection with client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection request from 127.0.0.1:63139
server sent connection challenge packet
server received connection response from 127.0.0.1:63139
server accepted client 127.0.0.1:63139 0000000000000269 in slot 1
server received connection payload packet from client 1
server confirmed connection with client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection response from 127.0.0.1:50364
server accepted client 127.0.0.1:50364 000000000000014d in slot 2
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected

@kienhg96
Copy link
Contributor Author

Right way:

Client =>

client started on port 62123
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client received connection keep alive packet from server
client changed state from 'sending connection response' to 'connected'
client connected to server
client received connection keep alive packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client received connection payload packet from server
client disconnected
client sent disconnect packets to server
client sent disconnect packet 0
client sent disconnect packet 1
client sent disconnect packet 2
client sent disconnect packet 3
client sent disconnect packet 4
client sent disconnect packet 5
client sent disconnect packet 6
client sent disconnect packet 7
client sent disconnect packet 8
client sent disconnect packet 9
client changed state from 'connected' to 'disconnected'


Server =>

server listening on 127.0.0.1:7777
reset encryption manager
server started with 64 client slots
server received connection request from 127.0.0.1:62123
server sent connection challenge packet
server received connection response from 127.0.0.1:62123
server accepted client 127.0.0.1:62123 00000000000002b9 in slot 0
server received connection payload packet from client 0
server confirmed connection with client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received disconnect packet from client 0
server disconnected client 0
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123
server could not process packet because no encryption mapping exists for 127.0.0.1:62123

@gafferongames
Copy link
Contributor

Hi, I'm trying to match the client logs with the server logs in the delay case.

In the client logs, I see various port numbers.

Then I look at the server logs, and I see different port numbers.

Are you certain that the server log corresponds to the complete server log in the delay case?

Here are the logs I'm working from:

DEBUG

client started on port 57447
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client received connection keep alive packet from server
^C

client started on port 57448
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client received connection challenge packet from server
client changed state from 'sending connection request' to 'sending connection response'
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
client sent connection response packet to server
^C

client started on port 54203
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C

client started on port 61792
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C

client started on port 61793
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
^C

client started on port 61794
client connecting to server 127.0.0.1:7777 [1/1]
client changed state from 'disconnected' to 'sending connection request'
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client sent connection request packet to server
client connect failed. connect token expired
client disconnected
client changed state from 'sending connection request' to 'connect token expired'

----------

server listening on 127.0.0.1:7777
reset encryption manager
server started with 64 client slots
server received connection request from 127.0.0.1:63138
server sent connection challenge packet
server received connection response from 127.0.0.1:63138
server accepted client 127.0.0.1:63138 0000000000000155 in slot 0
server received connection payload packet from client 0
server confirmed connection with client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection payload packet from client 0
server received connection request from 127.0.0.1:63139
server sent connection challenge packet
server received connection response from 127.0.0.1:63139
server accepted client 127.0.0.1:63139 0000000000000269 in slot 1
server received connection payload packet from client 1
server confirmed connection with client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection payload packet from client 1
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection request from 127.0.0.1:50364
server sent connection challenge packet
server received connection response from 127.0.0.1:50364
server accepted client 127.0.0.1:50364 000000000000014d in slot 2
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected
server received connection response from 127.0.0.1:50364
server ignored connection response. a client with this address is already connected

@gafferongames gafferongames self-assigned this Dec 21, 2023
@kienhg96
Copy link
Contributor Author

@gafferongames I think you are working on the "client log of failure case" with "server log of delay case". They are not on the same case.

@gafferongames
Copy link
Contributor

I think you are working on the "client log of failure case" with "server log of delay case". They are not on the same case.

Confirmed. Cross checking port numbers now and it seems to line up.

@gafferongames
Copy link
Contributor

I'm going to extend the logs, and try to repro over here

@gafferongames
Copy link
Contributor

Does this only happen when the server is running on windows, because I'm on Mac and I cannot repro it even though I have adjusted the client.c to remove the signal handler.

@kienhg96
Copy link
Contributor Author

Yes, it does only on Windows

@gafferongames
Copy link
Contributor

The good news is that since it is Windows specific, we can know that the issue is something in the socket receive processing, or the OS support for sockets. The logic is fine -- all logic is shared across all platforms.

@gafferongames
Copy link
Contributor

Following this logic, I think I know what it is:

        if ( error == WSAEWOULDBLOCK || error == WSAECONNRESET )
            return 0;

The WSACONNRESET is stopping packets from being received, and it's windows specific... should be able to fix, then you can verify.

@gafferongames
Copy link
Contributor

OK, I believe I have a fix checked in now. Let me know how it goes. The issue is windows specific.

@gafferongames
Copy link
Contributor

gafferongames commented Dec 22, 2023

The fix + explanation of what was going on:

    int result = recvfrom( socket->handle, (char*) packet_data, max_packet_size, 0, (struct sockaddr*) &sockaddr_from, &from_length );

#if NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS
    if ( result == SOCKET_ERROR )
    {
        int error = WSAGetLastError();

        if ( error == WSAEWOULDBLOCK )
            return 0;

        /*
            IMPORTANT: This happens on windows because a previous sendto on this socket went to an address + port
            belonging to a socket that was shut down forcefully (eg. OS closed the socket). 

            You can trigger this behavior by commenting out the client signal handler in client.c and then
            repeatedly connecting to the server.

            What happens is that we get the ICMP port unreacable message back, and that triggers the WSACONNRESET
            on the next recvfrom. This behavior is windows specific.

            If we just return 0, we will stop receiving packets for this frame, and this will streeeeeetch out packets
            and cause problems where clients can't connect or receive packets because each time we see the WSACONNRESET we
            stop processing packets for that frame.

            The solution is to just ignore the WSACONNRESET error, and call recvfrom again...
        */
        
        if ( error == WSAECONNRESET )
        {
            return netcode_socket_receive_packet( socket, from, packet_data, max_packet_size );
        }

        netcode_printf( NETCODE_LOG_LEVEL_ERROR, "error: recvfrom failed with error %d\n", error );

        return 0;
    }
#else // #if NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS

@kienhg96
Copy link
Contributor Author

I think the solution would resolve the issue. However, I have a question.

If in the previous frame, client does some sendtos, will recvfrom produce a lot of WSAECONNRESETs continously and lead netcode_socket_receive_packet to recusive calling very deeply and, maybe, stack overflow?

@gafferongames
Copy link
Contributor

Yes, the recursion is a bit gross, BUT, there is only one WSAECONNRESET per-packet sent from the server, so I think the recursion won't go on forever, it will be reasonable. Let me know if you see stack issues around the recursion, and if so we can refactor the socket receive function to iterate over recvfrom and ignore WSAECONNRESET until it gets a correct result.

@gafferongames
Copy link
Contributor

The only thing I worry about is DDoS spoofing ICMP packets. I would recommend that in production, you block ICMP to your servers.

@kienhg96
Copy link
Contributor Author

kienhg96 commented Dec 22, 2023

Thanks for your advice. I have checked the test case and the issue has gone.

@gafferongames
Copy link
Contributor

Closing this out. Thanks for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants