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

"Cannot access a disposed object" thrown OnClientDisconnect() #127

Open
Drakenfrost opened this issue Apr 7, 2023 · 2 comments
Open

"Cannot access a disposed object" thrown OnClientDisconnect() #127

Drakenfrost opened this issue Apr 7, 2023 · 2 comments

Comments

@Drakenfrost
Copy link

Drakenfrost commented Apr 7, 2023

Hi there.

This error only occurs:

  • on the server.
  • when the client disconnecting is NOT also a host. Hosts stop perfectly fine.

The error seems to be caused by the base implementation of 'OnStopClient' called from the base 'OnClientDisconnect' method.

I am using the Multiplex Transport but currently only have Telepathy running.

I've tried first removing the client's ownership of all their owned objects as well as the player object. This did not help.

Here is the log:

ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
  at System.Net.Sockets.Socket.ThrowIfDisposedAndClosed () [0x0001b] in <8c9cb336fa2042c285391d24de6e4092>:0 
  at System.Net.Sockets.Socket.get_RemoteEndPoint () [0x00000] in <8c9cb336fa2042c285391d24de6e4092>:0 
  at Telepathy.Server.GetClientAddress (System.Int32 connectionId) [0x00014] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\Telepathy\Telepathy\Server.cs:324 
  at Mirror.TelepathyTransport.ServerGetClientAddress (System.Int32 connectionId) [0x00002] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\Telepathy\TelepathyTransport.cs:197 
  at Mirror.MultiplexTransport.ServerGetClientAddress (System.Int32 connectionId) [0x00011] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\MultiplexTransport.cs:224 
  at Mirror.NetworkConnectionToClient.get_address () [0x00000] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\NetworkConnectionToClient.cs:10 
  at CustomNetworkManager.OnServerDisconnect (Mirror.NetworkConnectionToClient conn) [0x00009] in D:\Unity\Repos\WitheredWillows\Assets\ScriptLibrary\GuardianOfElderidge\Networking\CustomNetworkManager.cs:51 
  at Mirror.NetworkServer.OnTransportDisconnected (System.Int32 connectionId) [0x00027] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\NetworkServer.cs:600 
  at Mirror.MultiplexTransport+<>c__DisplayClass18_0.<AddServerCallbacks>b__3 (System.Int32 baseConnectionId) [0x00001] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\MultiplexTransport.cs:194 
  at Mirror.TelepathyTransport.<ServerStart>b__27_2 (System.Int32 connectionId) [0x00000] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\Telepathy\TelepathyTransport.cs:173 
  at Telepathy.Server.Tick (System.Int32 processLimit, System.Func`1[TResult] checkEnabled) [0x00098] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\Telepathy\Telepathy\Server.cs:382 
  at Mirror.TelepathyTransport.ServerEarlyUpdate () [0x00010] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\Telepathy\TelepathyTransport.cs:229 
  at Mirror.MultiplexTransport.ServerEarlyUpdate () [0x00012] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\Transports\MultiplexTransport.cs:35 
  at Mirror.NetworkServer.NetworkEarlyUpdate () [0x00010] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\NetworkServer.cs:1717 
  at Mirror.NetworkLoop.NetworkEarlyUpdate () [0x00001] in D:\Unity\Repos\WitheredWillows\Assets\Plugins\Mirror\Runtime\NetworkLoop.cs:193

(Filename: D:/Unity/Repos/WitheredWillows/Assets/Plugins/Mirror/Runtime/Transports/Telepathy/Telepathy/Server.cs Line: 324)

Currently I just commented out line 324 in Telepathy.Server which has the trouble method 'GetClientAddress' as seen at the top of the stack above.

Please let me know what further information I can provide. Thanks in advance for any assistance!

@GeekBrony
Copy link

GeekBrony commented Apr 7, 2023

I am also getting this issue with a regular .NET project and Telepathy, which I am using as a server app for my project.

When a client connects, the app receives the OnConnected call, but after that, fails.

It worked 4 months ago, now it doesn’t. Nothing changed in my project to make it fail like this.

Weird issue.

@GeekBrony
Copy link

Oops. I figured it out - there was an early disconnect call in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants