Closed sin0emp closed 4 years ago
Setting the socket option RouterMandatory
on the server side, will solve the problem!
Reading the description of this option, this option is related to cases when router fails to route the message. The original question still holds that, is why router is failing to deliver (why the connection is lost?). Another thing is that, it should only throw an exception in face of failing to route a message. So how come it affects the behavior of the above code? Is the description incomplete?
Set the RouterSocket behavior when an unroutable message is encountered. A value of false is the default and discards the message silently when it cannot be routed. A value of true causes throw of HostUnreachableException if the message cannot be routed.
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.
Environment
Expected behavior
Setting up a router to router client-server on a single machine, and sending a million messages from server side to the client side, it is expected to receive all the packets by the client. Giving that there is no problem with doing the same thing on a raw tcp socket.
Actual behavior
Randomly there are dropped or missed packets from the client side. Investigating further, I realized that setting the socket option
ReconnectInterval
to zero will cause the socket to not receive any further message after missing the first message. Hence I deduce that the problem is socket disconnection in the middle of the procedure which will result in reconnection attempts and in the meantime, the packets sent from the server will be lost. I know that zero mq is an at-most-once queue so one should expect to miss packets and be prepared for it. But my problem is that this setup is on a single machine, there is no physical network between them and there is no such problem with doing the same scenario on the underlying communication technology that is tcp socket. So, what will cause its tcp connection to be closed and then reconnect?Steps to reproduce the behaviour
Client Code:
Server Code:
Running client, then server, client gives an output like the following (missing 165 messages).