Closed tmuthmann closed 4 years ago
I cannot think of a good solution for this, because after you disconnect the socket get disposed by the framework.
Maybe instead of passing the Socket we can only pass some information but that will be a big change...
The only think I can think of is you managing a dictionary of Socket to remote endpoint (add the socket on Accepted and remove on Disconnected).
I don't see the reason, why closing the first socket disposes the second socket. I use two independent client classes, each with it's own Dealer socket and own monitor. So i expected no interference of any type between the two clients. Is there another solution to track connects and disconnects?
because once you dispose the client socket netmq recognize that and dispose the peer socket on the server side because the channel is close.
as I suggested you can manage a dictionary, on Accepted add the socket to a dictionary and the remoteEndpoint as value, on disconnected use the socket as key (don't use any of the properties) and get the remote endpoint from the dictionary.
That way you are not accessing the disposed object and can access the remote endpoint you saved on the dictionary.
There's a patch merged for this. Is this issue fixed?
This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.
Hello, I think this issue still exist. I'm try same way and get same error.
NetMQ: 4.0.1.13 C# .NET 6.0
The following example uses a ROUTER server and two DEALER clients connecting the server on localhost. I want to log all connects and disconnects from the server and all clients and used NetMQMonitor for this.
The Problem now is that the first call of repmon.Disconnected (after closing client1) has an useable socket, but on the second call of repmon.Disconnected (after closing client2) the socket "a.Socket" is already destroyed (CleanedUp is true) and so RemoteEndPoint is invalid.
I tested NetMQ 3.3.0.9 via NuGet using Visual Studio 2013, NET 4.5.
To test set an breakpoint on Line 76 (Console.WriteLine("test");), and run.
Now you get something like this:
now press a key in the console to stop client1 and you stop at the breakpoint. you now can inspect "a.Socket" and it is valid. continue the program and you get this:
now press a key in the console to stop client2 and you stop at the breakpoint. you now can inspect "a.Socket" and it is INVALID. RemoteEndPoint throws an exceptions, so only the first WriteLine with "test" goes out. continue the program and you get this:
I'm missing the Line:
used example: