How to resolve "NetMQ.AddressAlreadyInUseException" using ZeroMQ
Let me explain how I got this exception from such a simple code, I used the trading program cAlgo where I tried to start the NetMQ server, apparently stopping it, it does not close correctly, leaving the port unusable until the computer restarts.
I would like some help to restore this port and make it usable again, I tried to clear it without success, I am starting with ZeroMQ so I am not good at using it.
Thanks, added exception (with internal SocketException, only one use per socket address (protocol / network address / port).
void Main()
{
using (var server = new ResponseSocket("@tcp://localhost:5555")) // bind
using (var client = new RequestSocket(">tcp://localhost:5555")) // connect
{
// Send a message from the client socket
client.SendFrame("Hello");
// Receive the message from the server socket
string m1 = server.ReceiveFrameString();
Console.WriteLine("From Client: {0}", m1);
// Send a response back from the server
server.SendFrame("Hi Back");
// Receive the response from the client socket
string m2 = client.ReceiveFrameString();
Console.WriteLine("From Server: {0}", m2);
}
}
+3
source to share