MidLevel / Ruffles

Lightweight and fully managed reliable UDP library.
MIT License
212 stars 28 forks source link

Leaving Ruffles running for a certain period of time results in disconnects and exceptions #8

Closed poettlr closed 4 years ago

poettlr commented 4 years ago

Hi,

I'm currently testing ruffles, and before I say anything, you did amazing!

Currently, I try a small simulation of four RuffleSockets, one being the server and three the clients. Each 16 to 20ms all participating sockets send a 256-byte package. The server "broadcasts" the package to the three clients. The clients just send it directly to the server. Each socket creates its own packet, so they are not dependent on any information flow.

After about ~365,000 messages in total (~54000 received payloads on each client, and ~196000 payloads received on the server), each client receives a NetworkEvent with NetworkEventType.Disconnect.

The Disconnects are a couple of seconds apart (roughly the same time I need to press connect on each client). 13 seconds later the server throws a NullReferenceException and then logs that a particular client has disconnected.

NullReferenceException: Object reference not set to an instance of an object Ruffles.Memory.MemoryManager.DeAlloc (Ruffles.Memory.HeapPointers pointers) (at <f3d7047ed8d941c398bcc2452492ea15>:0) Ruffles.Messaging.PacketHandler.SendMessage (System.ArraySegment1[T] payload, Ruffles.Connections.Connection connection, System.Byte channelId, System.Boolean noDelay, Ruffles.Memory.MemoryManager memoryManager) (at :0) Ruffles.Core.RuffleSocket.Send (System.ArraySegment1[T] payload, Ruffles.Connections.Connection connection, System.Byte channelId, System.Boolean noDelay) (at <f3d7047ed8d941c398bcc2452492ea15>:0)

All this is run inside Unity 2018.4.9f1. It's a simple repo, I can provide access if needed. Unfortunately, I have no idea why the client suddenly thinks it is disconnected.

The Editor.log from Unity contains a bit of more information:

ClientEvent: Disconnect [WARNING] Client 123.123.123.123:5674 connection could not be found The warning is issued without a stack trace.

The server crash seems to be related to:

[ERROR] Outgoing packet window is exhausted. Disconnecting

This probably happens because I try to send via the ChannelType.Reliable channel.

I hope that helps to solve the issue, and or maybe you have ideas on how I can fix it on my side :)

TwoTenPvP commented 4 years ago

This has been resolved in the last release.