Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIP not working when running homeassistant without host networking #10

Open
mattkasa opened this issue May 10, 2023 · 4 comments
Open

Comments

@mattkasa
Copy link
Contributor

Logger: voip_utils.sip
Source: /usr/local/lib/python3.10/site-packages/voip_utils/sip.py:134
First occurred: 12:37:10 PM (3 occurrences)
Last logged: 1:54:58 PM

Unexpected error handling SIP INVITE
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/voip_utils/sip.py", line 123, in datagram_received
    self.on_call(
  File "/usr/local/lib/python3.10/site-packages/voip_utils/voip.py", line 53, in on_call
    sock.bind((call_info.server_ip, 0))
OSError: [Errno 99] Address not available

I think this is happening because the address (call_info.server_ip) is taken from the INVITE, which looks like this:

INVITE sip:192.168.1.10:5060 SIP/2.0

Without host networking, the homeassistant container has an IP like 172.26.0.20 and cannot bind to 192.168.1.10.

To fix this, maybe we could bind to INADDR_ANY instead of trusting the IP from the INVITE which will not be correct in a lot of networking scenarios?

Something like:

sock.bind(('', 0))

sock.bind((call_info.server_ip, 0))

@mattkasa
Copy link
Contributor Author

I just tried binding to INADDR_ANY and it works and gets farther, the next issue seems to be binding to a random port for RTP. We would need to bind to a known range of ports in order to expose those to the network, similarly to how frigate/go2rtc/rtsptoweb support configuring ranges of ports.

@synesthesiam
Copy link
Collaborator

I've added the bind to INADDR_ANY and verified it works on my end.
I'm not sure how to get the bind to work in a port range, though.

@deggle
Copy link

deggle commented May 18, 2023

Hi, I'm having this same issue (posted on Discord and was pointed here).

I (kinda) understand the docker networking, but I'm confused as to why the container can't bind to 192.168.1.10 - in my case, I can ping the calling IP, and even TCP connect to it - so this just routes though docker out to the LAN (outbound ports don't need to be mapped like inbound).

I'm going to try to change the .py file as per above and see if that works.

@deggle
Copy link

deggle commented May 18, 2023

So, I get a call connecting now, but no voice data coming though so I guess that's the port not getting though.
I'm on 'host' networking mode so I thought it may work.
I'm also seeing HA update the "Call in progress" flag but it never clears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants