Skip to content

Consider setting TCP_KEEPIDLE time in MLLP.Client #72

@starbelly

Description

@starbelly

We have made {:keepalive, true} a default in MLLP.Client. This requires adjusting system wide settings, which is not horrible, but it's also not great either. The default for most operating systems is pretty big and the idle timeout for some MLLP endpoint systems and/or middle boxes in the wild is small (e.g., 10 minutes, 15 minutes, 30 minutes), etc.

An option at our disposal is to set the client to use raw mode ({:packet, :raw}), this would allow us to set raw protocol options on the socket, such as TCP_KEEPIDLE time.

A bit of testing needs to be done and if the results are favorable, then we can provide a few new options to go with {:keepalive, true}. Namely, {:keepidle, N} where N is the amount of time a conn can sit idle before keepalive kicks in. We may also be interested in adding the other counter parts for that (e.g., interval, etc.)

In a nutshell, we have to :

  1. Check if keepalive is set to true
  2. Check if keepidle was set to a positive integer
  3. Check to see if we support the option, that is check the return value of:os.type/0,
  4. If it's supported, add the raw options.

Example for Linux and Mac OS :

{:raw, 6, 16, <<time::32-native-integer>>}

Where 6 is the protocol (tcp), 16 is the protocol option (keepidle), and time is the integer value (milliseconds) extracted from the provided option.

Note that normally I wouldn't consider this, but mllp has no probe support to keep a connection alive. It may be fine just to let the connection die and reconnect. However, if low latency is a goal for a user this is pretty essential.

It may be this an option best left up to the user vs putting it in here, but would be a nice to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions