Skip to content

TCP sockets left after closed connection from marinetraffic.com #63

@tjswe

Description

@tjswe

This is a pretty rare incident but i have spent a few hours finding the root cause so i want to create an issue for it.

I have two Raspberry Pi:s with USB-connected AIS-receivers in a remote location with low to no AIS-traffic that services a SAR function in the area.

Both Kplex:es on both Rpi:s are experiencing "Too many open files" from time to time. If kplex is restarted, problem is solved.

From what i can find (with my limited network knowledge) the issue comes from marinetraffic.com (from now on MT) expects NMEA-packets every 10 seconds or less. If no data is received they send a TCP FIN to the client and asks to end the connection. This probably for performance reasons.

If traffic then IS being sent by the client after these 10 seconds, MT responds with a RST which probably is a more harsh way to tell kplex that the listening socket in the other end is closed. (The AIS-traffic in the example below is a keepalive script that injects an NMEA-sentence to kplex every minute)

image

What i think this gives, is a lot of open sockets(?) which over time reaches a limit where kplex is not allowed to create any more (1024 max)

image

Not sure if this is due to how MT handles the connection or if this is an issue with kplex or my installation specifically.

As for the issue for me, its looks to be handled by adjusting the rate of keepalivepackets below 10 seconds. I have also read about the keepalive function that has been added to kplex. Still the number of unclosed sockets is an issue that perhaps could happen to others.

Details:

Running version 1.4-55-ga7d726b (develop branch Aug 4, 2022)

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions