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

Access WSS interface directly from within HA #45

Open
felipecrs opened this issue Jan 9, 2022 · 17 comments
Open

Access WSS interface directly from within HA #45

felipecrs opened this issue Jan 9, 2022 · 17 comments
Labels
enhancement New feature or request

Comments

@felipecrs
Copy link

felipecrs commented Jan 9, 2022

So that we don't need to forward an additional port in the router for making it work outside of the local network. This should also greatly simplify scenarios with Cloudflare.

This basically means that the sipjs-card would not communicate with Asterisk through the port 8089, but instead with the HA's https port. This also means that certificates do not need to be configured or added to Asterisk (most likely), as the Ingress should be configured to use port 8088 (non-TLS).

Some references:

https://warlord0blog.wordpress.com/2020/04/16/asterisk-webrtc/
https://developers.home-assistant.io/docs/add-ons/presentation#ingress
hassio-addons/addon-traccar@f3b00f4
https://github.com/hassio-addons/addon-ssh/blob/main/ssh/rootfs/etc/services.d/ttyd/run#L22-L23

Related:

#31 (@ErnestStaug as you are using Cloudflare)

@felipecrs felipecrs changed the title Somehow make WS endpoint be exposed within HA's ingress Expose WSS access through HA ingress Jan 9, 2022
@TECH7Fox TECH7Fox pinned this issue Jan 21, 2022
@TECH7Fox TECH7Fox added the enhancement New feature or request label Feb 2, 2022
@felipecrs
Copy link
Author

Initial support for ingress has been released in version 1.2.0. But some work will be required from the Integration as mentioned in TECH7Fox/asterisk-hass-addons#57 (comment).

@felipecrs felipecrs changed the title Expose WSS access through HA ingress Access WSS interface directly from within HA Feb 18, 2022
@felipecrs
Copy link
Author

Actually, no work is required from the addon side, and Ingress was actually not needed. All the work needed is from the integration, which needs to proxy the WSS interface (8089) of the addon to be accessed by the card directly from HA.

@TECH7Fox can you transfer this issue to the integration repo instead?

image

@TECH7Fox TECH7Fox transferred this issue from TECH7Fox/asterisk-hass-addons Feb 24, 2022
@TECH7Fox
Copy link
Owner

@felipecrs did you find any documentation on how to do this?

@felipecrs
Copy link
Author

@TECH7Fox I didn't find documentation, but there is an example:

https://github.com/blakeblackshear/frigate-hass-integration/blob/cbdfb4fe6493f629c7464b67429713b53a99b0ac/custom_components/frigate/views.py#L280

@miguelangel-nubla
Copy link

miguelangel-nubla commented Nov 28, 2023

Hi, did anyone manage to enable a workaround to make it work?

@miguelangel-nubla
Copy link

I managed to get wss proxy work using cloudflared addon

additional_hosts:
- hostname: sip.mydomain.com
  service: https://<hass-address>:8089

The card connects and registers correctly.
Calls start, WebRTC candidates showing up from ICE on both sides but no audio or video.
Shouldn't UDP hole punching with the STUN do the heavy lifting?

Is the addon configured to act as a proxy between the WebRTC clients, or only direct connection allowed?

@felipecrs
Copy link
Author

I managed to get wss proxy work using cloudflared addon

That's exactly what I do too, for more than a year so far. :D

For those not using cloudflared, it's easily possible to make it work similarly using the NGINX Proxy Manager add-on.

@miguelangel-nubla
Copy link

miguelangel-nubla commented Nov 28, 2023

Does it work for you over WAN with a cellular connection for example?
Do you manually forward any ports to the asterisk server for the media?

@felipecrs
Copy link
Author

felipecrs commented Nov 28, 2023

I don't forward any ports. And yes, calling through Asterisk still works when I'm not home. (we are still talking about cloudflared, right?)

@miguelangel-nubla
Copy link

we are still talking about cloudflared, right?

I am not sure I follow.

I am talking opened ports for WebRTC for the audio/video to the Asterisk server after the cloudflared connection "proxy" has registered and served the candidates.

As far as I understand the wss connection via cloudflare is only for registering and candidate exchange, audio/video travels over WebRTC which is what I am having issue with.

@pergolafabio
Copy link
Contributor

i believe for audio and video you need to open the RTP ports too (public access), then webrtc is not enough

@felipecrs
Copy link
Author

felipecrs commented Nov 28, 2023

I did not know I had to open extra ports. I thought everything was happening through the WSS port.

So I guess I'm lucky, because I don't have any ports open in my router (except go2rtc's webrtc 8555 for Frigate). Everything else goes through cloudflared.

@pergolafabio
Copy link
Contributor

but you only use the card on local lan?

@felipecrs
Copy link
Author

No, it works outside home too. Or when using cellular data.

@pergolafabio
Copy link
Contributor

Ah good to know, i dont use the wss, i thought it was needed too like for softphones

@felipecrs
Copy link
Author

felipecrs commented Nov 28, 2023

Oh man. My bad. I had always believed it was working, but I guess I was only counting on the fact that the card shows as connected, and that the call also connects.

I am testing now, and although the card and Asterisk believes the call is happening, there is no audio.

@miguelangel-nubla
Copy link

Sorry to hear that, guess there is some piece missing.

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

No branches or pull requests

4 participants