eavanvalkenburg / pysiaalarm

A python package to connect to a SIA DC-09 based alarm system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Socket exhaustion with SIA

Phyks opened this issue · comments

Hi,

I am using the asyncio version of pysiaalarm as per the test example (https://github.com/eavanvalkenburg/pysiaalarm/blob/master/tests/run_aio.py) and I am regularly getting errors such as

févr. 21 02:05:29 domotique python[2711]: ERROR - 2022-02-21 02:05:29 - asyncio: socket.accept() out of system resource
févr. 21 02:05:29 domotique python[2711]: socket: <asyncio.TransportSocket fd=13, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8001)>
févr. 21 02:05:29 domotique python[2711]: Traceback (most recent call last):
févr. 21 02:05:29 domotique python[2711]:   File "/usr/lib/python3.9/asyncio/selector_events.py", line 164, in _accept_connection
févr. 21 02:05:29 domotique python[2711]:     conn, addr = sock.accept()
févr. 21 02:05:29 domotique python[2711]:   File "/usr/lib/python3.9/socket.py", line 293, in accept
févr. 21 02:05:29 domotique python[2711]:     fd, addr = self._accept()
févr. 21 02:05:29 domotique python[2711]: OSError: [Errno 24] Too many open files

I am using pysialarm with an Ajax alarm system.

It seems that for some reason pysiaalarm is not releasing sockets. See

$ lsof | grep 8001  | wc -l
12000

all of them being between my Ajax hub IP and pysiaalarm system (connection status "ESTABLISHED") with a bunch of different source ports on the Ajax hub IP side.

Upon restart of the client app, I only get

$ lsof | grep 8001  | wc -l
15

10 being LISTEN status on *:8001 (pysiaalarm listener) and 5 being ESTABLISHED between my Ajax hub (single source port) and pysiaalarm.

Has anyone already noticed this behavior?

Thanks!

i haven't, but it could be due to cancelling main not closing a async with properly, you could try adding a catch for keyboardinterrrupt and manually opening and closing the connection

Update on this one, it is kinda solved. My Ajax alarm was connected to the same LAN with Wifi and Ethernet fallback. Disabling Wifi fixed the issue.