Skip to content

exception when disconnecting one of many clients in a console application #129

@PyrateAkananto

Description

@PyrateAkananto

It is possible to create multiple clients within a single console application (.NET 6 on Windows in my case). But if I create more than one client and then call Disconnect on the clients "usually" an error message including an exception is written to the console (see below).

When creating just one client that error does not appear. When creating two or three clients this error "sometimes" appears, but not always. When creating four or more clients this error "usually" appears, for some but not all created clients. This behavior obviously is not deterministic.

Attached is TelepathyExperiment.cs.txt which is a minimal example. In it the amount of created game clients is set as a command line parameter.

Am I using Telepathy in a wrong way? Is this expected behavior? Or is this not intended and could be fixed in Telepathy?

ReceiveLoop: finished receive function for connectionId=0 reason: System.Threading.ThreadInterruptedException: Thread was interrupted from a waiting state.
   at System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken)
   at System.Resources.ResourceManager.AddResourceSet(Dictionary`2 localResourceSets, String cultureName, ResourceSet& rs)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at System.Resources.ResourceManager.GetString(String name)
   at System.SR.GetResourceString(String resourceKey)
   at System.SR.get_net_io_readfailure()
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Telepathy.NetworkStreamExtensions.ReadSafely(NetworkStream stream, Byte[] buffer, Int32 offset, Int32 size) in C:\MyProject\Telepathy\NetworkStreamExtensions.cs:line 18
   at Telepathy.NetworkStreamExtensions.ReadExactly(NetworkStream stream, Byte[] buffer, Int32 amount) in C:\MyProject\Telepathy\NetworkStreamExtensions.cs:line 55
   at Telepathy.ThreadFunctions.ReadMessageBlocking(NetworkStream stream, Int32 MaxMessageSize, Byte[] headerBuffer, Byte[] payloadBuffer, Int32& size) in C:\MyProject\Telepathy\ThreadFunctions.cs:line 55
   at Telepathy.ThreadFunctions.ReceiveLoop(Int32 connectionId, TcpClient client, Int32 MaxMessageSize, MagnificentReceivePipe receivePipe, Int32 QueueLimit) in C:\MyProject\Telepathy\ThreadFunctions.cs:line 121

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions