Wrote client-server data transfer using ØMQ. Judging by the description, if ØMQ is disconnected, it should reconnect itself. If I manually disconnect the server part of the program, it reconnects, if I manually disconnect the network card, it reconnects. But if you pull out the power cord for a long time, then when you connect it back, the client side stops at "Waiting for an answer ...", server part at "Waiting for a client". How to make it connect with this disconnect?

Client code:

int i = 0; var context = new ZContext(); using (var client = new ZSocket(context, ZSocketType.REQ)) { client.Connect("tcp://192.168.1.13:5555"); while (true) { i++; Console.WriteLine("Отправляю"); client.Send(new ZFrame(i.ToString())); Console.WriteLine("Отправил: " + i); Thread.Sleep(1000); Console.WriteLine("Жду ответа..."); using (ZFrame reply = client.ReceiveFrame()) { Console.WriteLine(" Получил: " + reply.ReadString()); } 

Server code:

  var context = new ZContext(); using (var responder = new ZSocket(context, ZSocketType.REP)) { responder.Bind("tcp://*:5555"); while (true) { Console.WriteLine("Жду клиента"); using (ZFrame request = responder.ReceiveFrame()) { Console.WriteLine("Получено: "+ request.ReadString()); Console.WriteLine("Отправляю ответ"); responder.Send(new ZFrame("Success")); } } } 

PS Found a more detailed description of the problem HERE , but I can't figure out how to solve it.

    1 answer 1

    Use ReceiveFrame with timeout

    • How exactly do this? Where to specify timeout? - Nikolay
    • Why the hell is there a time out? What are you going to do in case of a timeout? - Pavel Mayorov
    • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky
    • The reason for stopping in case of disconnection of the power cord is most likely that ReceiveFrame is blocked. To unlock it and need a timeout. I don’t know if there is a timeout mechanism in ZerMuC, if it’s not there, you need to do something like this - Michael K.