While troubleshooting inside a container without host networking, and setting the RTP bind port to a single port, I noticed the socket is never closed until you restart homeassistant.
The first call works, but then the second call fails with a 512 because the address is already in use.
It probably hasn't been noticed yet because it's randomly binding 1 of 65536 ports, but eventually your system will run out of ports unless we close them, and because it's random, at any point it could try to bind a port that it had already previously bound.
This change fixes it for me and I can place repeat calls without errors, but it feels strange to just put a close here without being in a callback, so if there is a better way to fix this, I'd be happy to learn :+1:
While troubleshooting inside a container without host networking, and setting the RTP bind port to a single port, I noticed the socket is never closed until you restart homeassistant.
The first call works, but then the second call fails with a
512
because the address is already in use.It probably hasn't been noticed yet because it's randomly binding 1 of 65536 ports, but eventually your system will run out of ports unless we close them, and because it's random, at any point it could try to bind a port that it had already previously bound.
This change fixes it for me and I can place repeat calls without errors, but it feels strange to just put a close here without being in a callback, so if there is a better way to fix this, I'd be happy to learn :+1: