AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.31k stars 355 forks source link

Stale online connections #25

Closed oischinger closed 2 years ago

oischinger commented 2 years ago

Hey there, thanks for this amazing project. Works perfect for me. However I noticed that sometimes the go2rtc web interface shows an "online" connection to a camera from e.g. my mobiule phone's browser even though I closed that tab long time ago and even when put the fone in airplane mode. It seems like this connection is "stale".

I wonder if there's a way to cope with this situation. Any ideas how I could further debug this?

Thanks!

AlexxIT commented 2 years ago

Do you using alpha 11?

oischinger commented 2 years ago

Yes

AlexxIT commented 2 years ago

Are you sure this is connection from your phone and not, for example, Hass, or something else?

oischinger commented 2 years ago

It must be the phone because of the useragent I see under "info"

AlexxIT commented 2 years ago

You need to enable env variable PION_LOG_DEBUG=all

oischinger commented 2 years ago

I captured the logs of such a scenario:

18:21:13.729 INF [api] listen addr=:1984
18:21:13.729 INF [rtsp] listen addr=:8554
 - set_ws - connect
 on_open - executed
 - WebSocket message sent. %s {"messageId": "start_listening", "command": "start_listening"}
 - WebSocket message sent. %s {"messageId": "set_api_schema", "command": "set_api_schema", "schemaVersion": 11}
 - WebSocket message sent. %s {"messageId": "driver_connect", "command": "driver.connect"}
 - process_messages started
on_message - {'type': 'result', 'success': True, 'messageId': 'set_api_schema', 'result': {}}
on_message - {'type': 'result', 'success': True, 'messageId': 'start_listening', 'result': {'state': {'driver': {'version': '2.1.2', 'connected': True, 'pushConnected': True}, 'stations': [{'name': 'Turklingel', 'model': 'T8200', 'serialNumber': 'T8200N0020280C6C', 'hardwareVersion': 'P2', 'softwareVersion': '2.345', 'lanIpAddress': '192.168.178.73', 'macAddress': '8C858047B51A', 'currentMode': 1, 'guardMode': 1, 'connected': True}], 'devices': [{'name': 'Turklingel', 'model': 'T8200', 'serialNumber': 'T8200N0020280C6C', 'hardwareVersion': 'P2', 'softwareVersion': '2.345', 'stationSerialNumber': 'T8200N0020280C6C', 'enabled': True, 'motionDetected': False, 'personDetected': False, 'personName': '', 'ringing': False, 'autoNightvision': True, 'motionDetection': True, 'watermark': 0, 'pictureUrl': 'https://cdn-eu.eufylife.com/thumb/2022/08/31/station/T8200N0020280C6C/DwPlvYe8NVdwRGlT./video_20220831_194941.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYLV2KOLW6PU4FSA%2F20220831%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20220831T181523Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=e557ad01d4841165aa9c51c7bc5da3b540c018d8711d7a44da83ce64163c2cef', 'ledStatus': False}]}}}
Accepting connection for  Audio
Accepting connection for  Video
on_message - {'type': 'result', 'success': True, 'messageId': 'driver_connect', 'result': {}}
pc INFO: 2022/08/31 20:22:49 signaling state changed to have-remote-offer
ice DEBUG: 20:22:49.982512 agent.go:457: Started agent: isControlling? false, remoteUfrag: "19n/", remotePwd: "MEOvz8StQQSqblxZQ1jngJ/S"
ice INFO: 2022/08/31 20:22:49 Setting new connection state: Checking
pc INFO: 2022/08/31 20:22:49 ICE connection state changed: checking
ice WARNING: 2022/08/31 20:22:49 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
New connection added:  ('127.0.0.1', 36300)  for  Audio
 - WebSocket message sent. %s {"messageId": "start_livesteam", "command": "device.start_livestream", "serialNumber": "T8200N0020280C6C"}
ice WARNING: 2022/08/31 20:22:50 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:50 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:50 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:50 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
on_message - {'type': 'result', 'success': True, 'messageId': 'start_livesteam', 'result': {}}
ice WARNING: 2022/08/31 20:22:50 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:51 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:51 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:51 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:51 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:51 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
New connection added:  ('127.0.0.1', 52254)  for  Video
 - WebSocket message sent. %s {"messageId": "start_livesteam", "command": "device.start_livestream", "serialNumber": "T8200N0020280C6C"}
on_message - {'type': 'result', 'success': False, 'messageId': 'start_livesteam', 'errorCode': 'device_livestream_already_running'}
pc INFO: 2022/08/31 20:22:52 signaling state changed to have-remote-offer
ice DEBUG: 20:22:52.185758 agent.go:457: Started agent: isControlling? false, remoteUfrag: "JwOB", remotePwd: "a3AxdKFMKPZtwYOJGJIA5/3H"
ice INFO: 2022/08/31 20:22:52 Setting new connection state: Checking
pc INFO: 2022/08/31 20:22:52 ICE connection state changed: checking
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:52 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:53 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
pc INFO: 2022/08/31 20:22:54 signaling state changed to stable
pc INFO: 2022/08/31 20:22:54 signaling state changed to stable
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 could not get server reflexive address udp6 stun:stun.l.google.com:19302: write udp6 [::]:60762->[2a00:1450:400c:c00::7f]:19302: sendto: network is unreachable
ice WARNING: 2022/08/31 20:22:54 could not get server reflexive address udp6 stun:stun.l.google.com:19302: write udp6 [::]:51529->[2a00:1450:400c:c00::7f]:19302: sendto: network is unreachable
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:54 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice INFO: 2022/08/31 20:22:54 Setting new connection state: Connected
pc INFO: 2022/08/31 20:22:54 ICE connection state changed: connected
pc INFO: 2022/08/31 20:22:54 peer connection state changed: connected
sender_interceptor WARNING: 2022/08/31 20:22:54 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:54 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:55 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:55 failed sending: the DTLS transport has not started yet
pc INFO: 2022/08/31 20:22:56 signaling state changed to have-remote-offer
ice DEBUG: 20:22:56.676564 agent.go:457: Started agent: isControlling? false, remoteUfrag: "Jp3A", remotePwd: "quhPoSZV7na9rx3bmXB2a4Td"
ice INFO: 2022/08/31 20:22:56 Setting new connection state: Checking
ice WARNING: 2022/08/31 20:22:56 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
pc INFO: 2022/08/31 20:22:56 ICE connection state changed: checking
pc INFO: 2022/08/31 20:22:56 signaling state changed to stable
ice WARNING: 2022/08/31 20:22:56 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice WARNING: 2022/08/31 20:22:56 could not get server reflexive address udp6 stun:stun.l.google.com:19302: write udp6 [::]:48004->[2a00:1450:400c:c00::7f]:19302: sendto: network is unreachable
ice WARNING: 2022/08/31 20:22:56 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice INFO: 2022/08/31 20:22:56 Setting new connection state: Connected
pc INFO: 2022/08/31 20:22:56 ICE connection state changed: connected
pc INFO: 2022/08/31 20:22:56 peer connection state changed: connected
pc WARNING: 2022/08/31 20:22:56 Incoming unhandled RTCP ssrc(4156352737), OnTrack will not be fired
sender_interceptor WARNING: 2022/08/31 20:22:56 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:56 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:57 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:57 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:58 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:58 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:59 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:22:59 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:00 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:00 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:01 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:01 failed sending: the DTLS transport has not started yet
ice INFO: 2022/08/31 20:23:02 Setting new connection state: Disconnected
pc INFO: 2022/08/31 20:23:02 ICE connection state changed: disconnected
pc INFO: 2022/08/31 20:23:02 peer connection state changed: disconnected
pc WARNING: 2022/08/31 20:23:02 Failed to accept RTP stream is already closed
pc WARNING: 2022/08/31 20:23:02 Failed to accept RTCP stream is already closed
ice INFO: 2022/08/31 20:23:02 Setting new connection state: Closed
pc INFO: 2022/08/31 20:23:02 peer connection state changed: closed
pc INFO: 2022/08/31 20:23:02 ICE connection state changed: closed
sender_interceptor WARNING: 2022/08/31 20:23:02 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:02 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:03 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:03 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:04 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:04 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:05 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:05 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:06 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:06 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:07 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:07 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:08 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:08 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:09 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:09 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:10 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:10 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:11 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:11 failed sending: the DTLS transport has not started yet
ice INFO: 2022/08/31 20:23:12 Setting new connection state: Disconnected
pc INFO: 2022/08/31 20:23:12 ICE connection state changed: disconnected
pc INFO: 2022/08/31 20:23:12 peer connection state changed: disconnected
pc WARNING: 2022/08/31 20:23:12 Failed to accept RTCP stream is already closed
pc WARNING: 2022/08/31 20:23:12 Failed to accept RTP stream is already closed
ice INFO: 2022/08/31 20:23:12 Setting new connection state: Closed
pc INFO: 2022/08/31 20:23:12 peer connection state changed: closed
pc INFO: 2022/08/31 20:23:12 ICE connection state changed: closed
sender_interceptor WARNING: 2022/08/31 20:23:12 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:12 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:13 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:13 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:14 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:14 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:15 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:15 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:16 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:16 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:17 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:17 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:18 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:18 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:19 failed sending: the DTLS transport has not started yet
sender_interceptor WARNING: 2022/08/31 20:23:19 failed sending: the DTLS transport has not started yet
ice INFO: 2022/08/31 20:23:20 Setting new connection state: Failed
pc INFO: 2022/08/31 20:23:20 ICE connection state changed: failed
pc INFO: 2022/08/31 20:23:20 peer connection state changed: failed
ice INFO: 2022/08/31 20:23:20 Setting new connection state: Closed
pc INFO: 2022/08/31 20:23:20 peer connection state changed: closed
pc WARNING: 2022/08/31 20:23:20 Failed to start manager: connecting canceled by caller
pc WARNING: 2022/08/31 20:23:20 undeclaredMediaProcessor failed to open SrtcpSession: the DTLS transport has not started yet
pc INFO: 2022/08/31 20:23:20 ICE connection state changed: closed
pc WARNING: 2022/08/31 20:23:20 undeclaredMediaProcessor failed to open SrtpSession: the DTLS transport has not started yet

The web interface shows 2 active connections. Here's the 'Info':

[{"media:0":"audio, sendonly, 96 OPUS/48000/2","media:1":"video, sendonly, 97 H264/90000","receive":3327404,"remote_addr":"[::1]:55394","send":0,"track:0":"97 H264/90000, sinks=1","type":"RTSP server producer","url":"rtsp://localhost:8554/329e77f78b955ab000c152366ea9f2a6","user_agent":"Lavf59.16.100"},{"remote_addr":"","send":3333301,"type":"WebRTC server consumer","user_agent":"Mozilla/5.0 (Linux; Android 10; BLA-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Mobile Safari/537.36"}]
AlexxIT commented 2 years ago

I think I've found a mistake, thanks! Will be fixed in next release. Should work fine in current release with default Hass lovelace card.

oischinger commented 2 years ago

I dont think this is reproducable anymore with the beta. thanks!