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

Linphone fixes #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

glance-
Copy link

@glance- glance- commented May 11, 2023

This fixes two issues I found when testing linphone against voip-utils in home-assistant.

glance- added 3 commits May 11, 2023 21:08
When testing this lib with linphone, it was discovered that linphone
uses CRLF Keep-Alive as described in:
https://www.rfc-editor.org/rfc/rfc5626#section-3.5.1

This adds detection of them and debug-logs the detection to ignore it.

Otherwise this caused some false-positive errors in the logs, creating
confusion.
There where two sets of CRLF between the headers and the body, which
causes issues when linphone parses the sip message.

This uses some minimal trickery to ensure that there's only one set of
CRLF between the headers and the body in sip answers.
linphone tries to send STUN Binding Requests, which causes a fatal
exception. Just ignore these and linphone works with voip-utils.
@glance-
Copy link
Author

glance- commented May 11, 2023

With these 3 fixes, I have gotten as far as I hear the "There's a problem with the current voice assistant settings"... which is a completely different issue on my side.

I think this gets us far enough to make the linphone softphone usable.

@synesthesiam synesthesiam self-assigned this May 12, 2023
@glance-
Copy link
Author

glance- commented Jun 8, 2023

Any news on this one?

@2m
Copy link

2m commented Jul 31, 2023

@glance- glad to see you put effort into making linphone work with voip-utils. What would be the easiest way for me to test these changes on my HA setup?

@glance-
Copy link
Author

glance- commented Jul 31, 2023

Depends quite heavily on what your HA setup is, but generally, just applying the changes to the relevant files in your virtual-env or container, is the quickest and dirtiest approach. Cloning the repo, checking out the pr and installing it in your venv or extending the base container "upgraded" with this package is another one.

@2m
Copy link

2m commented Jul 31, 2023

Thank you for the hints!

I am running HA OS and have successfully installed your patched version with:

docker exec -it homeassistant bash
pip install git+https://github.com/glance-/voip-utils.git@linphone-fixes

However I still get the same error when trying to make a call from linphone:

Unexpected error handling SIP INVITE

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/voip_utils/sip.py", line 63, in datagram_received
    method, ruri, headers, body = self._parse_sip(message)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voip_utils/sip.py", line 224, in _parse_sip
    method = line_parts[0]
             ~~~~~~~~~~^^^
IndexError: list index out of range

@2m
Copy link

2m commented Jul 31, 2023

Aha! I needed to disable media encryption in linphone. And now it works! But it works with both, latest code from home-assistant-libs/voip-utils and also with this fix from your branch.

All in all I did the following in linphone to make it work:

  1. Settings -> Audio -> Codecs -> Disabled all and left only opus on
  2. Settings -> Call -> Media Encryption -> None
  3. Settings -> Click on the SIP account -> Outbound proxy -> Disabled

@balloob
Copy link
Contributor

balloob commented May 17, 2024

@glance- sorry this PR got stuck. We are not looking that much into voip right now. Have you tested this with a grandstream ht801 to ensure that this keeps working?

Also, since I have some VoIP enthusiasts in this PR: I've opened a bounty to make outbound calls work.

@glance-
Copy link
Author

glance- commented May 17, 2024

I don't have access to any grandstream ht801, but i doubt that these changes would break anything. It's basically just more actual sip compatibility.

@synesthesiam synesthesiam added the bug Something isn't working label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants