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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.