jasonrbriggs / stomp.py

“stomp.py” is a Python client library for accessing messaging servers (such as ActiveMQ or RabbitMQ) using the STOMP protocol (versions 1.0, 1.1 and 1.2). It can also be run as a standalone, command-line client for testing.
Apache License 2.0
491 stars 167 forks source link

try_setsockopt() usage in transport.py broken on Mac #391

Closed PalNilsson closed 1 year ago

PalNilsson commented 2 years ago

Hi,

On Macs, this

        if try_setsockopt(self.socket, "enable", SOL_SOCKET, SO_KEEPALIVE, 1):
            try_setsockopt(self.socket, socket.IPPROTO_TCP, 0x10, ka_intvl)

leads to the error

try_setsockopt() missing 1 required positional argument: 'val'

Can you please check?

Regards, Paul

zkan commented 2 years ago

This happened to me too. Right now I work around by changing this code here: https://github.com/jasonrbriggs/stomp.py/blob/dev/stomp/transport.py#L661 from

    def __enable_keepalive(self):
        def try_setsockopt(sock, name, fam, opt, val):
            if val is None:
                return True  # no value to set always works

to

    def __enable_keepalive(self):
        def try_setsockopt(sock, name, fam, opt, val=None):
            if val is None:
                return True  # no value to set always works
jasonrbriggs commented 1 year ago

Made that change for the next version. I don't have a mac test environment (other than a virtualbox mac install, which I haven't bothered configuring for stomp), so no idea if it works or not, but seems like a low-enough-impact fix.