go2rtc icon indicating copy to clipboard operation
go2rtc copied to clipboard

Reolink doorbell cant turn off backchannel

Open pilipovicn opened this issue 4 months ago • 5 comments

I got a Reolink D340W, and frigate 0.16.1-e664cb2, with bundled go2rtc 1.9.9.

This is the go2rtc config.

go2rtc:
  streams:
    front_door:
      - rtsp://*snip*:*snip*@10.0.3.21:554/h264Preview_01_sub
      - ffmpeg:front_door#audio=opus#audio=copy
  webrtc:
    candidates:
      - 10.0.1.10:8555
      - stun:8555

All works more or less well. Home Assistant Advanced camera card successfully utilizes 2way audio. It also works on frigate UI. Both HTTPS. This is how 2way works (at least on the stock reolink app): The stream is 1way, but after I press the mic button, it becomes 2way, and the ring light on the doorbell lights up blue, to signify someone is talking on the mic, i.e. backchannel is open. While this is so, the doorbell cannot be rang, or at least the chime doesn't ring. This is not a problem, since when I disable the mic in the app, the backchannel mode is turned off, as is the light, and the bell works again.

Not with go2rtc however, ths is the problem. When starting frigate and go2rtc, the light is off. But the moment I click the mic in HomeAssistant, and it opens the backchannel, and the mic works, the light turns on. That's all good so far, but here lies the problem: It can never be turned off again. The light stays on, as if the camera is still in 2way mode. Even after I turn off the mic, close the tab, etc.

Same problem if I watch through frigate, except it seems to open the backchannel right off the bat, before clicking the mic, and so the light is blue from the start.

I checked go2rtc info page. When I click the mic icon, this backchannel appears (if I'm correct):

"receivers": [
        {
          "id": 89,
          "codec": {
            "codec_name": "pcm_mulaw",
            "codec_type": "audio",
            "sample_rate": 8000
          },
          "childs": [
            90
          ],
          "bytes": 13440,
          "packets": 84
        }
      ],

After I close the tab, or the HA Card automatically closes backchannel, this channel disappears, and mic no longer works. BUT the light is still on, and the doorbell doesn't work. Even though the channel is gone, somehow the device is still stuck in 2-way mode.

Only way to turn it off is to kill frigate/go2rtc (fully killing the consumer could work as well, didn't try), or to go into official reolink app, and click the mic button, which will immediately toggle the 2-way mode off.

Does anyone have a hint on how to remedy this?

pilipovicn avatar Sep 06 '25 14:09 pilipovicn

This card uses different connections or even different streams for two way audio. So when you closing stream with two way - this frees up the backchannel. https://github.com/AlexxIT/WebRTC?tab=readme-ov-file#two-way-audio

If the backchannel is already open and you continue to watch videos and audio, it will remain open. You need to stop watching and reconnect without the backchannel.

AlexxIT avatar Sep 07 '25 11:09 AlexxIT

I was using the Advanced Camera Card, but I tried with yours, might be a better test since author is same.

Yes I understand the connection has to be remade to remove the backchannel. But it seems it is not properly terminated/remade.

First I thought the problem was with the Advanced (Frigate) Card. But now that I tried yours, it seems the problem is similar, or at least there could be a connection. Please take a look at the issue I posted here, it explains the problem, which is similar with this card.

To reproduce the problem on this card, I set up two HA tabs, one with WebRTC Card with options video,audio. Second one with capabilities video,audio,microphone. I watched port 554 on camera for incoming packets. I open the tab without microphone, it loads up RTC stream succesfully. All normal in wireshark.

I switch to the card with microphone capabilities. In Wireshark the previous connection is reset and abandoned. Source port changes signifying a new connection. Stream loads, mic works, all good.

I switch back to the card with no microphone, stream loads, browser turns off mic. But the connection stays the same. Wireshark confirms, same src port used, no resets to the previous connection.

This leaves my doorbell camera in 2-way mode (conversation mode, signifyed by blue light), unable to be rung (and recording ring events).

This wouldn't be a major problem, since closing the tab or leaving it for some time kills the connection. But I (and I suppose a good number of people) have the android app, and it's set up with no background restrictions, for gps accuracy, quick alerts, and so on. This makes it so that once I open the backchannel card stream on the phone, the connection is never broken and my camera always stays on in 2way mode.

Seems like go2rtc resets the connection when adding the backchannel capability, but not when subtracting the backchannel. Or am I wrong? Similar problem with Advanced Card: clicking the mic to turn it on resets the connection. But after the timer expires to remove backchannel, it doesn't reset it.

pilipovicn avatar Sep 09 '25 01:09 pilipovicn

Show your config for WebRTC card

AlexxIT avatar Sep 09 '25 14:09 AlexxIT

Not much to show, two tabs with two cards. First card:

type: custom:webrtc-camera
streams:
  - url: front_door
    mode: webrtc
    media: video,audio

Second card with mic:

type: custom:webrtc-camera
streams:
  - url: front_door
    mode: webrtc
    media: video,audio,microphone

pilipovicn avatar Sep 09 '25 17:09 pilipovicn

You can create front_door1 and front_door2 with same source. And better to add #backchannel=0 to front_door1. So it will be two different sources for go2rtc.

With your config go2rtc will use same stream from first and for second card. If the backchannel is no longer needed, it will still remain connected.

AlexxIT avatar Sep 10 '25 07:09 AlexxIT