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

Version 2.0.1: HTTP 500 response from /api/<name>/reset_rotation #746

Open
csammis opened this issue Mar 17, 2023 · 5 comments
Open

Version 2.0.1: HTTP 500 response from /api/<name>/reset_rotation #746

csammis opened this issue Mar 17, 2023 · 5 comments

Comments

@csammis
Copy link

csammis commented Mar 17, 2023

edit: camera is a Wyze V3 Pan

Updated to :latest (2.0.1) this evening and found an issue with the reset_rotation API endpoint. Logs here:

[snoopy] [CONTROL] 
[snoopy] [CONTROL] Response: {'cmd': 'reset_rotation', 'status': 'error', 'response': Empty()}
[snoopy] [CONTROL] Request: reset_rotation via WEB-UI!
[2023-03-16 21:56:14,966] ERROR in app: Exception on /api/snoopy/reset_rotation [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1826, in full_dispatch_request
    return self.finalize_request(rv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1845, in finalize_request
    response = self.make_response(rv)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 2156, in make_response
    rv = self.json.response(rv)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/json/provider.py", line 309, in response
    f"{self.dumps(obj, **dump_args)}\n", mimetype=mimetype
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/json/provider.py", line 230, in dumps
    return json.dumps(obj, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/json/provider.py", line 122, in _default
    raise TypeError(f"Object of type {type(o).__name__} is not JSON serializable")
TypeError: Object of type Empty is not JSON serializable
[WyzeBridge] 192.168.86.141 - - [16/Mar/2023 21:56:14] "GET /api/snoopy/reset_rotation HTTP/1.1" 500 -
[snoopy] [CONTROL] 
[snoopy] [CONTROL] Response: {'cmd': 'reset_rotation', 'status': 'error', 'response': Empty()}
@csammis
Copy link
Author

csammis commented Mar 17, 2023

After testing a bit more it seems like the 500 response doesn't always happen when hitting the reset_response endpoint - sometimes the API returns {"command":"reset_rotation","response":"camera busy","status":"error"}. I haven't been able to determine a rhyme or reason to it yet.

mrlt8 added a commit that referenced this issue Mar 17, 2023
@mrlt8
Copy link
Owner

mrlt8 commented Mar 17, 2023

Thanks! There were some backend changes to the way the commands are handled in v2.0.0.

I pushed some changes to ignore the response from K11004ResetRotatePosition. Could you try the edge build and see if that fixes it?

@csammis
Copy link
Author

csammis commented Mar 18, 2023

That fixes the 500 response!

I think I figured out what's going on with the status: error situation as well. Turns out the camera control commands will work once after sending /api/<name/start and then return status: error on each subsequent invocation until /start is sent again. What's interesting is that it looks like the bridge is not sending any commands to the camera when the API response is status: error. Using tcpdump on the docker host I don't see any communication with the camera's IP - but when the control commands are working I do see UDP traffic to port 47398 on the camera. Is this expected behavior? If no, happy to open a new issue and help debug however I can!

@mrlt8
Copy link
Owner

mrlt8 commented Mar 18, 2023

The current version of the bridge starts a control thread for each camera after it establishes a connection to that camera for streaming, so the commands should continue to work as long as there is some streaming going on.

Will have to see if we might be able to keep the connection alive when there isn't any video streaming.

@csammis
Copy link
Author

csammis commented Mar 19, 2023

Thanks, that makes sense! My use case involves movement that may not (probably won't) occur during streaming - using home assistant to set the camera's rotation all the way down when I arrive home, so like a faux privacy mode. Now that the server behavior's cleared up I can check if the camera's connected via /status and issue /start if necessary prior to the movement command.

In any event I'd say this specific issue can be closed :)

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

No branches or pull requests

2 participants