mas-bandwidth / netcode

Secure client/server connections over UDP
BSD 3-Clause "New" or "Revised" License
2.44k stars 191 forks source link

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

Closed kienhg96 closed 11 months ago

kienhg96 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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

kienhg96 commented 11 months ago
  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 commented 11 months ago

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

gafferongames commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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
kienhg96 commented 11 months ago

@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 commented 11 months ago

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 commented 11 months ago

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

gafferongames commented 11 months ago

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 commented 11 months ago

Yes, it does only on Windows

gafferongames commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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

gafferongames commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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

kienhg96 commented 11 months ago

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

gafferongames commented 11 months ago

Closing this out. Thanks for your report!