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

Fails to syncronize some recordings, resulting in endless retries #523

Closed
vitorsemeano opened this issue Feb 22, 2024 · 2 comments · Fixed by JurajNyiri/pytapo#102
Closed
Labels
Bug Something isn't working Help wanted Extra attention is needed

Comments

@vitorsemeano
Copy link

vitorsemeano commented Feb 22, 2024

Description

After enabling synchronization of recordings, I can see almost all recordings of my tapo camera.

My camera is a tapo C220.

Problem is that some specific records fails to complete the download. When I go the the sync entity in home asssistant i can see it tries to download specific record and after some time, jumps to retry, then download, in a endless loop of the same record(s). Majority of them succeeds and i am able to view them in home assistant.

the behavior is something like this:

imagem
imagem

Reproduction Steps

  1. Configure device to sincronize recordings (custom storage path and default does not bring any difference)
  2. Produce some recordings until a specific one triggers this effect
  3. see sync worker in a loop retrying to fetch the same recording

Expected behavior

I would hope that the download completes and stops retrying.

If applicable, add error logs.

Seeing the logs i have this errors (fragment of it but all errors found about this integration are more of these):

2024-02-22 11:30:01.785 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:33:14.332 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:33:24.304 WARNING (MainThread) [custom_components.tapo_control] Failed to get file from cold storage: /tapoControl//videos/1708588904-1708589086.mp4
2024-02-22 11:35:07.841 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:36:48.576 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:36:58.577 WARNING (MainThread) [custom_components.tapo_control] Failed to get file from cold storage: /tapoControl//videos/1708174687-1708174778.mp4
2024-02-22 11:40:01.896 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:43:14.442 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered
2024-02-22 11:43:24.396 WARNING (MainThread) [custom_components.tapo_control] Failed to get file from cold storage: /tapoControl//videos/1708588904-1708589086.mp4
2024-02-22 11:45:07.786 WARNING (MainThread) [pytapo.media_stream.session] Received response with no or invalid session information (sequence None, session None), can't be delivered

Device Firmware

1.1.6 Build 231208 Rel.66881n

Integration Version

5.4.14

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Docker on ubuntu server 22.04 lts

Search for similar issues

Yes

Additional information

I also found this similar issues but not sure if related:

JurajNyiri/pytapo#93

#499

In the meantime, i disabled the sync worker, because this endless retries brings my camera unresponsive after some time.

@vitorsemeano
Copy link
Author

Following this issue, i made some debug in the existing py files in pytapo lib (hardcoded logging) and i managed to grab what was causing this abrupt failure and eventual retry.

For the file session.py, method _device_response_handler_loop, it triggers the following error: "Received response with no or invalid session information". I placed here logs to indicate the content of the request that was causing this error, and i got this:

headers:

b'\r\nContent-Type: application/json\r\nContent-Length: 85\r\nX-If-Encrypt: 0\r\n\r\n'

body:

b'{"type":"notification", "params":{"event_type":"stream_status", "status":"finished"}}'

What causes this method to fail is the missing session information in headers or in the body. This is also happening before all segments are expected to be sent. So for a length of 91, this is happening at the length of 81.

I am not familiar with the inter works of this lib, but i believe that a case can be placed when this body is received, terminating the reception of more chunks from the server because there aren't, according to this body.

Do you think this is a plausible solution for this situation? Let me know

@JurajNyiri
Copy link
Owner

Thank you for the investigation @vitorsemeano .

Yes I do think that would be a good solution. I have never seen that message before, must be new or maybe they fixed some bug they had before.

Is this something you could try opening a PR for? It would be hard for me to test/debug this since I am not encountering the error myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Help wanted Extra attention is needed
Projects
None yet
2 participants