Open stephan57160 opened 1 month ago
OK. I digged deeper in LIBZMQ:
libzmq/src/tcp_listener.cpp
.As I found no way to get this socket from ZYRE, I hard-coded a few setsockopts() after accept()/accept4() call, to reset the connection after 3mn40.
Are you suggesting to fix this in libzmq in zyre or in czmq?
As a preamble, I found one of our ZYRE servers with more than 700 sockets open since its last restart (a few weeks). Among them, more than 270 were established with the same remote (Android device).
Then, I went deeper and started to investigate a bit.
Finally, I came to reproduce this, with a the C source code below and a basic scenario described later:
Scenario to reproduce
On A, I observe 2 active TCP connexions (to simplify):
Now, unplug the Ethernet cable on B. After a few seconds, A shows an event "EXIT" from B and 1 socket is automatically closed, the 2nd socket (
A <-- B
) remains active:If the cable is plugged back, 2 new sockets are created, but the former
A <-- B
is still present:Repeat the operation and more sockets are seen.
I was hoping that if ZYRE (or the layers below) are able to close the socket
A --> B
, it could close the 2nd one as well. At least, something is detected "correctly", as 2 new sockets are created when B comes back.This comes more problematic when B is a laptop (or an Android device), coming in and out of WIFI coverage, or if the laptop is closed (hybernate) but not shut down.
I tried to play with TCP_KEEPALIVE, but without any kind of success so far.
The issue below looks related, actually: