-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to execute ZMQ_TCP_KEEPALIVE for my application. #3017
Comments
You forgot to mention what exactly the problem is. Also you probably need to set ZMQ_TCP_KEEPALIVE_INTVL and ZMQ_TCP_KEEPALIVE_CNT. Those are all OS-dependent flags, so you'll want to consult your OS manual to find out what the default values are and what the suggested configuration is. |
i have added TCP_KeepALIVE code and TCP_keepAlive_IDLE code. My problem is that publisher is not sending TCP packets to the SUB so what is happening is the socket is remaining idle, Once the socket remains idle for around 40s, sub thinks that something is blocking and tries to disconnect and reconnect itself. what i want is to send TCP keepalive packets to the sub from the pub. How can i achieve it. is my code ok or do i need to add something. |
The default on Linux is very long, are you sure setting the options is not making things nworse? |
Any update? |
@bluca I also happen to this issue. And I set all the keepalive option like this:
The result like this: |
Try to use the heartbeat options instead, which use the same mechanism but inside the protocol rather than at the TCP level |
@bluca I find the reason why heatbeat don't work. |
You can search online how to correctly set up cross compilation using autotools, we are not doing anything special |
I have an application that uses ZMQ Pub-Sub Model. I have an algorithm in my sub side that if the socket remains idle for 40 seconds it should disconnect and reconnect again. Now, I want to remove this algorithm. Instead i want to use TCP KeepAlive Packets so that my socket does not remain idle and thus my sub does not disconnect and connect frequently.
Please find my code below:
zmq_socket_t socket;
socket = zmq_socket(_zmq_context, ZMQ_PUB);
int tcp_keepalive = 1, tcp_keepalive_idle = 25;
if(zmq_setsockopt(socket, ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof(tcp_keepalive))) {
INFO(0, "sanjay keepalive error -err %d", tcp_keepalive);
return NULL;
}
else
{
INFO(0, "keepalive set -noerr %d", tcp_keepalive);
}
if(zmq_setsockopt(socket, ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof(tcp_keepalive_idle)))
{
INFO(0, "keepalive idle error -err %d", tcp_keepalive_idle);
return NULL;
}
else
{
INFO(0, "idle set -noerr %d", tcp_keepalive_idle);
}
if (zmq_bind(socket, urlp)) {
ERR(0, "zmq_bind(PUB): %s", ERRNO);
FREE(urlp);
return NULL;
}
Please help me on this ?? I am not able to achieve my target. Am i missing anything?
The text was updated successfully, but these errors were encountered: