1

I am just Started Using NETMQ REQ/RES pattern to send and receive the request response from both ends. Client is from IIS and server is from windows service. My question is when i had stopped the service and tried a client request. The client went to infinite LOOP and doesnt return.

Server Code

using (var server = new ResponseSocket())
{
    server.Bind("tcp://10.150.0.242:5556");
    while (true)
    {
        try
        {
            // using (var client = ctx.CreateRequestSocket())
            {
                string fromClientMessage = server.ReceiveString();
                string result = DigitalSignInitialization(fromClientMessage);
                server.Send(result);
                Console.WriteLine("From Client: {0}", fromClientMessage);
            }
        }
        catch(Exception Ex) { server.Send("Failure"); }

    }
}

Client Code

using (NetMQContext ctx = NetMQContext.Create())
{ 
     using (var client = ctx.CreateRequestSocket())
     {
         //try
        // {
        //client.Connect("tcp://10.150.0.242:5556");
        client.Connect(strNCODE_ADDRESS);
                    client.Send(json);

        fromServerMessage = client.ReceiveString(new TimeSpan (0, 0, 0, 30));
                                    if(fromServerMessage != "Success")
        {
            fromServerMessage="Failure";

            return "<RESULT><DIGITAL_SIGNATURE>DIgital Signature Failed</DIGITAL_SIGNATURE></RESULT>";
        }
    }
}

Code cant able to return . Please help me thanks in advance

vela
  • 147
  • 10

1 Answers1

1

This is normal behavior. 0MQ sockets does not fail if other endpoint disconnects. Instead socket Send method will await until server became available. If it is not desired behavior you should either use dontWait argument of the Send method or redesign entire approach in polling data from server.

Ari0nhh
  • 5,720
  • 3
  • 28
  • 33
  • How Poller can work in the absense of server. will it return client immediately about server not running/ able communicate. – vela Feb 10 '20 at 06:42