Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

KCP - created with cookie

Open Ghetaldus opened this issue 1 year ago • 2 comments

Describe the bug Spam with "created with cookie" with different cookie numbers is coming up when client gets timeout and then returns to the game. For example when user minimize his app on the android and then returns after timeout have occured, his connection does not drop instantly but instead spam with cookies goes on for a while before disconnect happens.

[IMPORTANT] How can we reproduce the issue, step by step: Please tell us how to reproduce your issue, STEP BY STEP, with one of our built in examples.

  • Import latest Mirror version from git
  • Open scene MirrorBasic from Basic example and enable debug for KCP
  • Switch build target to Android and build it
  • Start in Unity editor as server only
  • Run your build as a client (I've used Bluestacks 5 emulator here)
  • Minimize your app on the device and wait 10s for timeout and server to disconnect the client
  • Now maximize back client's app and watch server's logs in Unity editor
  • There will be plenty of lines with "[KCP] kcp2k.KcpServerConnection: created with cookie=1884780640" (see screenshot bellow)

Expected behavior "created with cookie" should not be spammed so many times

Desktop (please complete the following information):

  • OS: Windows 10
  • Build target: Android
  • Unity version: 2021.3.35 & 2022.3.21
  • Mirror branch: 89.6.0
created_with_cookie

Ghetaldus avatar Mar 26 '24 08:03 Ghetaldus

To add that I've just found out that this seems to happen only when using emulator to run your app. Tested now with 2 real different devices and it did not reproduce with these.

Ghetaldus avatar Mar 26 '24 09:03 Ghetaldus

Assuming these are packets from the previous connection still arriving at the server, we could check if the cookie is 0 before creating the connection @miwarnec? https://github.com/MirrorNetworking/Mirror/blob/9c9cc043b361891d3233d455e6c282931e0e2421/Assets/Mirror/Transports/KCP/kcp2k/highlevel/KcpServer.cs#L311-L347

imerr avatar Mar 26 '24 10:03 imerr

I believe this is fixed in newer Mirror versions.

JesusLuvsYooh avatar Jun 19 '24 09:06 JesusLuvsYooh

I believe this is fixed in newer Mirror versions.

Yes, this one is fixed now. Just tested it with 89.9.0.

Ghetaldus avatar Jun 20 '24 11:06 Ghetaldus