MirrorNetworking / kcp2k

MIT License
275 stars 47 forks source link

cookie warnings #54

Open miwarnec opened 10 months ago

miwarnec commented 10 months ago

this one seems hard to reproduce. gathering user reports in this thread.

https://discord.com/channels/343440455738064897/467961162558865408/1167190009401585814

Any ideas what would cause this to be spammed in console for headless dedicated server build? 

    Mirror v81.3.1
    Using dedicated server linux build with il2cpp
    Unity version 2022.2.10

This occasionally happens when I start the server, other times it works just fine (does not print this message).
I haven't spent much time looking into it, but wondering if anyone has seen this?

Thu Oct 26 19:32:45 UTC 2023: Mirror.NetworkLoop:NetworkEarlyUpdate()
Thu Oct 26 19:32:45 UTC 2023:
Thu Oct 26 19:32:45 UTC 2023: KcpPeer: dropped message with invalid cookie: 0 expected: 1052116154.

this left like 3mb log in like a few hours of running with how often it was printing, restarted the server without changing anything else and it's gone
13ice commented 8 months ago

The latest code version, still by this issue

13ice commented 8 months ago

The client is unity and the server is a C# console program. The above problem will still occur with a low probability.

13ice commented 8 months ago

I found the problem. The reason is that segment retransmission occurred before the Client received the Hello packet.

MrGadget1024 commented 7 months ago

I was able to reproduce this and hack a workaround.

The Problem:

Server has multiple IP's and the server is listening on all of them, but client is calling by FQDN that points to an IP that is not first in the list of IP's configured on the NIC. When client tries to connect, the cookie response goes out on the first IP, not the one the client called on, so client never gets the cookie message, doesn't respond, and gets kicked for timeout (the log spam is a byproduct of client trying to coax the cookie msg out of the server).

Solution A

Change your DNS to point the FQDN to the first IP on the NIC, or move the IP that it's pointed to up to be first on the NIC.

Solution B

1) Disable Dual Mode on the Kcp Transport 2) Change Line 144 in KcpServer.cs from this socket.Bind(new IPEndPoint(IPAddress.Any, port)); to this socket.Bind(new IPEndPoint(IPAddress.Parse("1.2.3.4"), port)); (replace 1.2.3.4 with your actual IP you want to bind to)

Solution C

A future PR that provides for entering IP or FQDN in Unity and use that for the binding above.

imerr commented 7 months ago

Further reading: https://stackoverflow.com/q/3062205 via https://stackoverflow.com/a/1309534 https://blog.powerdns.com/2012/10/08/on-binding-datagram-udp-sockets-to-the-any-addresses

miwarnec commented 4 months ago

quick update. 'invalid cookie=0' warnings.

this is reproducable with 30 bots in a local project. client sends Hello as reliable. kcp spits out the message one or multiple times until acked. server gets the first hello, sets as authenticated server gets another hello that was in transit for ack, shows the warning that we got cookie=0 while authenticated.

solutions: researching. maybe send hello as unreliable to avoid the ack stuff and check easily if msg=hello then ignore cookie=0 because in transit