mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
added keepalive zmq socket option (after 60s of idle time, 10 probes every sec. Mainly because an issue at Max IV (#956)
This commit is contained in:
parent
782c8abd9a
commit
588d11dedf
@ -109,6 +109,7 @@ class ZmqSocket {
|
|||||||
/**
|
/**
|
||||||
* Constructor for a server
|
* Constructor for a server
|
||||||
* Creates socket, context and connects to server
|
* Creates socket, context and connects to server
|
||||||
|
* socket option: keep alive added
|
||||||
* @param portnumber port number
|
* @param portnumber port number
|
||||||
* @param ethip is the ip of the ethernet interface to stream zmq from
|
* @param ethip is the ip of the ethernet interface to stream zmq from
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +76,32 @@ ZmqSocket::ZmqSocket(const uint16_t portnumber, const char *ethip)
|
|||||||
sockfd.serverAddress = oss.str();
|
sockfd.serverAddress = oss.str();
|
||||||
LOG(logDEBUG) << "zmq address: " << sockfd.serverAddress;
|
LOG(logDEBUG) << "zmq address: " << sockfd.serverAddress;
|
||||||
|
|
||||||
|
// Socket Options for keepalive
|
||||||
|
// enable TCP keepalive
|
||||||
|
int keepalive = 1;
|
||||||
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE, &keepalive, sizeof(keepalive))) {
|
||||||
|
PrintError();
|
||||||
|
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE");
|
||||||
|
}
|
||||||
|
// set the number of keepalives before death
|
||||||
|
keepalive = 10;
|
||||||
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_CNT, &keepalive, sizeof(keepalive))) {
|
||||||
|
PrintError();
|
||||||
|
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_CNT");
|
||||||
|
}
|
||||||
|
// set the time before the first keepalive
|
||||||
|
keepalive = 60;
|
||||||
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_IDLE, &keepalive, sizeof(keepalive))) {
|
||||||
|
PrintError();
|
||||||
|
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_IDLE");
|
||||||
|
}
|
||||||
|
// set the interval between keepalives
|
||||||
|
keepalive = 1;
|
||||||
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_INTVL, &keepalive, sizeof(keepalive))) {
|
||||||
|
PrintError();
|
||||||
|
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_INTVL");
|
||||||
|
}
|
||||||
|
|
||||||
// bind address
|
// bind address
|
||||||
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
|
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
|
||||||
PrintError();
|
PrintError();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user