fuatakgun / eufy_security

Home Assistant integration to manage Eufy Security devices as cameras, home base stations, doorbells, motion and contact sensors.
889 stars 73 forks source link

RTSP connection lost: [Errno 104] Connection reset by peer #753

Closed Kudzushi closed 10 months ago

Kudzushi commented 1 year ago

Hello! I am trying to use my Eufy 2 pro cameras via RTSP, but the stream keeps crashing with this error:

Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:100
First occurred: 21:50:48 (35 occurrences)
Last logged: 22:17:23

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 854, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiortsp/rtsp/reader.py", line 97, in run_stream
    async with RTSPMediaSession(conn, self.media_url, transport=transport, logger=self.logger) as sess:
  File "/usr/local/lib/python3.10/site-packages/aiortsp/rtsp/session.py", line 66, in __aexit__
    await self.teardown()
  File "/usr/local/lib/python3.10/site-packages/aiortsp/rtsp/session.py", line 154, in teardown
    resp = await self._send('TEARDOWN')
  File "/usr/local/lib/python3.10/site-packages/aiortsp/rtsp/session.py", line 165, in _send
    return await self.connection.send_request(method, url or self.media_url, headers)
  File "/usr/local/lib/python3.10/site-packages/aiortsp/rtsp/connection.py", line 278, in send_request
    resp = await asyncio.wait_for(self.active_requests[cseq], timeout or self.default_timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
aiortsp.rtsp.errors.RTSPConnectionError: RTSP connection lost: [Errno 104] Connection reset by peer
Kudzushi commented 1 year ago

1EBF4D50-6D74-4199-A025-10009EC157F8 A46B7296-2BA4-4515-9F11-2398C566A9BC

And such errors in WebRTC camera card.

Kudzushi commented 1 year ago
Logger: custom_components.eufy_security
Source: custom_components/eufy_security/eufy_security_api/web_socket_client.py:86
Integration: Eufy Security ([documentation](https://github.com/fuatakgun/eufy_security), [issues](https://github.com/fuatakgun/eufy_security/issues))
First occurred: 09:31:45 (2 occurrences)
Last logged: 09:41:45

Unexpected error fetching eufy_security data:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/eufy_security/coordinator.py", line 85, in _update_local
    await self._api.poll_refresh()
  File "/config/custom_components/eufy_security/eufy_security_api/api_client.py", line 160, in poll_refresh
    await self._send_message_get_response(OutgoingMessage(OutgoingMessageType.poll_refresh))
  File "/config/custom_components/eufy_security/eufy_security_api/api_client.py", line 343, in _send_message_get_response
    await self.send_message(message.content)
  File "/config/custom_components/eufy_security/eufy_security_api/api_client.py", line 352, in send_message
    await self._client.send_message(json.dumps(message))
  File "/config/custom_components/eufy_security/eufy_security_api/web_socket_client.py", line 86, in send_message
    raise WebSocketConnectionError()
custom_components.eufy_security.eufy_security_api.exceptions.WebSocketConnectionError
1mfaasj commented 1 year ago

Same issue here

amosyuen commented 1 year ago

Also getting the Unexpected error fetching eufy_security data: log and wrong response on DESCRIBE in webrtc card.

be1er commented 1 year ago

Hello, same issue here. Stream and/or Refresh of Preview Image with RTSP Streams not working.

adabelleleiram commented 1 year ago

Same issue here using a Indoor Cam Pan&Tilt 2K.

Logger: homeassistant.components.stream.stream.camera.kids_bedroom Source: components/stream/init.py:434 Integration: Stream (documentation, issues) First occurred: July 9, 2023 at 4:07:55 PM (113 occurrences) Last logged: 8:43:06 PM

Error from stream worker: Stream ended; no additional packets Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://192.168.1.205/live0 Error from stream worker: Error demuxing stream: [Errno 110] Operation timed out: 'rtsp://192.168.1.205/live0'

adabelleleiram commented 1 year ago

FYI, I timed it today and noticed that this happens after exactly 5 mins of streaming. I created an automation that turns the camera off then on again every 5 minutes. It works but it's an annoying workaround, especially since I use my camera as a baby monitor (turning the camera off and on exits fullscreen).

kusmierz commented 1 year ago

probably the same issue, but different exception source:

 2023-08-19 22:55:51.700 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
 Traceback (most recent call last):
   File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 989, in _read_ready__data_received
     data = self._sock.recv(self.max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ConnectionResetError: [Errno 104] Connection reset by peer

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "/usr/local/lib/python3.11/site-packages/aiortsp/rtsp/reader.py", line 97, in run_stream
     async with RTSPMediaSession(conn, self.media_url, transport=transport, logger=self.logger) as sess:
   File "/usr/local/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 66, in __aexit__
     await self.teardown()
   File "/usr/local/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 154, in teardown
     resp = await self._send('TEARDOWN')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 165, in _send
     return await self.connection.send_request(method, url or self.media_url, headers)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.11/site-packages/aiortsp/rtsp/connection.py", line 278, in send_request
     resp = await asyncio.wait_for(self.active_requests[cseq], timeout or self.default_timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
     return fut.result()
            ^^^^^^^^^^^^
 aiortsp.rtsp.errors.RTSPConnectionError: RTSP connection lost: [Errno 104] Connection reset by peer
Guerric-P commented 10 months ago

Exact same problem here, the stream stops working after exactly 5 minutes.

Homeassistant logs :

2023-10-22 00:54:34.744 INFO (MainThread) [aiortsp.rtsp.reader] try loading stream rtsp://192.168.1.27/live0
2023-10-22 00:54:34.750 INFO (MainThread) [aiortsp.rtsp.reader] connected!
2023-10-22 00:54:34.751 INFO (MainThread) [aiortsp.rtsp.reader] receiving interleaved RTP (0) and RTCP (1)
2023-10-22 00:54:34.754 INFO (MainThread) [aiortsp.rtsp.reader] session options: {'TEARDOWN', 'SETUP', 'PLAY', 'DESCRIBE', 'GET_PARAMETER', 'OPTIONS'}
2023-10-22 00:54:34.758 INFO (MainThread) [aiortsp.rtsp.reader] connection to RTSP server 192.168.1.27:554 closed (error: None)
2023-10-22 00:54:35.262 INFO (MainThread) [aiortsp.rtsp.reader] try loading stream rtsp://192.168.1.27/live0
2023-10-22 00:54:35.268 INFO (MainThread) [aiortsp.rtsp.reader] connected!
2023-10-22 00:54:35.269 INFO (MainThread) [aiortsp.rtsp.reader] receiving interleaved RTP (0) and RTCP (1)
2023-10-22 00:54:35.273 INFO (MainThread) [aiortsp.rtsp.reader] session options: {'TEARDOWN', 'SETUP', 'PLAY', 'DESCRIBE', 'GET_PARAMETER', 'OPTIONS'}
2023-10-22 00:54:35.276 INFO (MainThread) [aiortsp.rtsp.reader] connection to RTSP server 192.168.1.27:554 closed (error: None)
2023-10-22 00:54:35.780 INFO (MainThread) [aiortsp.rtsp.reader] try loading stream rtsp://192.168.1.27/live0
2023-10-22 00:54:35.785 INFO (MainThread) [aiortsp.rtsp.reader] connected!
2023-10-22 00:54:35.786 INFO (MainThread) [aiortsp.rtsp.reader] receiving interleaved RTP (0) and RTCP (1)
2023-10-22 00:54:35.789 INFO (MainThread) [aiortsp.rtsp.reader] session options: {'TEARDOWN', 'SETUP', 'PLAY', 'DESCRIBE', 'GET_PARAMETER', 'OPTIONS'}
2023-10-22 00:54:35.795 INFO (MainThread) [aiortsp.rtsp.reader] setting up using URL: rtsp://192.168.1.27/live0/trackID=0
2023-10-22 00:54:35.798 INFO (MainThread) [aiortsp.rtsp.reader] stream correctly setup: <Response status=200 msg="OK"" headers={'cseq': '3', 'transport': 'RTP/AVP/TCP;unicast;destination=192.168.0.103;source=192.168.0.102;interleaved=0-1', 'session': '123456902'} content-length=0>
2023-10-22 00:54:35.799 INFO (MainThread) [aiortsp.rtsp.reader] session id: 123456902, timeout: 60, keep_alive: 54
2023-10-22 00:54:35.799 INFO (MainThread) [aiortsp.rtsp.reader] playing stream...
2023-10-22 00:54:35.799 INFO (MainThread) [aiortsp.rtsp.reader] start playing rtsp://192.168.1.27/live0 at time `now` and speed `1`...
2023-10-22 00:54:35.834 INFO (MainThread) [aiortsp.rtsp.reader] stopping stream...
2023-10-22 00:54:35.834 INFO (MainThread) [aiortsp.rtsp.reader] stopping session/playback...
2023-10-22 00:54:35.890 INFO (MainThread) [aiortsp.rtsp.reader] connection to RTSP server 192.168.1.27:554 closed (error: [Errno 104] Connection reset by peer)
2023-10-22 00:54:35.890 INFO (MainThread) [aiortsp.rtsp.reader] connection closed, error: RTSP connection lost: [Errno 104] Connection reset by peer
2023-10-22 00:59:07.475 ERROR (stream_worker) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 989, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/deps/lib/python3.11/site-packages/aiortsp/rtsp/reader.py", line 97, in run_stream
    async with RTSPMediaSession(conn, self.media_url, transport=transport, logger=self.logger) as sess:
  File "/config/deps/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 66, in __aexit__
    await self.teardown()
  File "/config/deps/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 154, in teardown
    resp = await self._send('TEARDOWN')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/deps/lib/python3.11/site-packages/aiortsp/rtsp/session.py", line 165, in _send
    return await self.connection.send_request(method, url or self.media_url, headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/deps/lib/python3.11/site-packages/aiortsp/rtsp/connection.py", line 278, in send_request
    resp = await asyncio.wait_for(self.active_requests[cseq], timeout or self.default_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
aiortsp.rtsp.errors.RTSPConnectionError: RTSP connection lost: [Errno 104] Connection reset by peer
2023-10-22 00:59:39.808 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.camera_salon] Error from stream worker: Stream ended; no additional packets
2023-10-22 00:59:49.826 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.camera_salon] Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://192.168.1.27/live0
2023-10-22 01:00:09.844 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.camera_salon] Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://192.168.1.27/live0
2023-10-22 01:00:39.855 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.camera_salon] Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://192.168.1.27/live0

Go2rtc logs:

00:54:54.917 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:54:54.921 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:55:36.909 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:55:36.911 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:59:28.686 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:59:28.686 INF [streams] create new stream url=rtsp://192.168.1.27/live0
00:59:39.744 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="read tcp 10.89.0.2:43760->192.168.1.27:554: i/o timeout" url=rtsp://192.168.1.27/live0
00:59:39.744 WRN github.com/AlexxIT/go2rtc/internal/streams/producer.go:171 > error="read tcp 10.89.0.2:39974->192.168.1.27:554: i/o timeout" url=rtsp://192.168.1.27/live0
01:01:10.358 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:10.361 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:10.525 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:10.831 ERR github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:166 > error="streams: wrong response on DESCRIBE"
01:01:44.159 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:44.160 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:44.337 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:01:44.635 ERR github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:166 > error="streams: wrong response on DESCRIBE"
01:02:31.417 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:02:31.424 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:02:31.589 INF [streams] create new stream url=rtsp://192.168.1.27/live0
01:02:31.900 ERR github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:166 > error="streams: wrong response on DESCRIBE"

I don't even know if this is a problem related to the integration or to the camera itself.

fuatakgun commented 10 months ago

@adabelleleiram @Guerric-P , original RTSP stream is managed by the hardware but not the integration. For some reason, sometimes, the stream is not accessible and all the consumers are not happy with it but I can do nothing about strength of hardware supported RTSP stream.