Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

cookie warnings #54

Open
miwarnec opened this issue Oct 28, 2023 · 6 comments
Open

cookie warnings #54

miwarnec opened this issue Oct 28, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@miwarnec
Copy link
Collaborator

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
@miwarnec miwarnec added the bug Something isn't working label Oct 28, 2023
miwarnec pushed a commit that referenced this issue Oct 28, 2023
…ie, client now always checks the cookie, client now always includes the cookie
miwarnec pushed a commit to MirrorNetworking/Mirror that referenced this issue Oct 28, 2023
- fix: mismatching cookie race condition. cookie is now included in all messages.
   MirrorNetworking/kcp2k#54
- feature: Exposed local end point on KcpClient/Server
- refactor: KcpPeer refactored as abstract class to remove KcpServer initialization workarounds
miwarnec pushed a commit to MirrorNetworking/Mirror that referenced this issue Oct 28, 2023
- fix: mismatching cookie race condition. cookie is now included in all messages.
   MirrorNetworking/kcp2k#54
- feature: Exposed local end point on KcpClient/Server
- refactor: KcpPeer refactored as abstract class to remove KcpServer initialization workarounds
miwarnec pushed a commit to MirrorNetworking/Mirror that referenced this issue Oct 29, 2023
- fix: mismatching cookie race condition. cookie is now included in all messages.
   MirrorNetworking/kcp2k#54
- feature: Exposed local end point on KcpClient/Server
- refactor: KcpPeer refactored as abstract class to remove KcpServer initialization workarounds
miwarnec added a commit to MirrorNetworking/Mirror that referenced this issue Oct 29, 2023
- fix: mismatching cookie race condition. cookie is now included in all messages.
   MirrorNetworking/kcp2k#54
- feature: Exposed local end point on KcpClient/Server
- refactor: KcpPeer refactored as abstract class to remove KcpServer initialization workarounds
@13ice
Copy link

13ice commented Jan 9, 2024

The latest code version, still by this issue

@13ice
Copy link

13ice commented Jan 9, 2024

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

@13ice
Copy link

13ice commented Jan 18, 2024

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

@MrGadget1024 MrGadget1024 reopened this Jan 30, 2024
@MrGadget1024
Copy link
Contributor

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.

@miwarnec
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants