You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Python WebSocket API attempts to connect with a truncated authentication token, which results in a ConnectionClosedOK exception saying "received 1000 (OK); then sent 1000 (OK)" when running cosmos_web_socket_example.py with COSMOS Open Source.
To Reproduce
Change the OpenC3 API password to my own in cosmos_web_socket_example.py
Run cosmos_web_socket_example.py
Get the following traceback: Traceback (most recent call last): File "c:\Users\...\cosmos_web_socket_example.py", line 24, in <module> with StreamingWebSocketApi() as api: File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 62, in __exit__ self.disconnect() File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 153, in disconnect self.unsubscribe() File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 110, in unsubscribe self.stream.write(json.dumps(json_hash)) File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\streams\web_socket_client_stream.py", line 50, in write self.connection.send(data) File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\websockets\sync\connection.py", line 281, in send with self.send_context(): File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\websockets\sync\connection.py", line 715, in send_context raise self.protocol.close_exc from original_exc websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)
Change line 131 of web_socket_api.py from final_url = self.url + f"?scope={self.scope}&authorization={self.authentication.token()[7:]}"
to final_url = self.url + f"?scope={self.scope}&authorization={self.authentication.token()}"
Run cosmos_web_socket_example.py again
Successfully receive and print all the requested items.
Environment
OS: Windows 11
OpenC3 COSMOS Open Source 5.18.0
Browser: Chrome
The text was updated successfully, but these errors were encountered:
Describe the bug
The Python WebSocket API attempts to connect with a truncated authentication token, which results in a ConnectionClosedOK exception saying "received 1000 (OK); then sent 1000 (OK)" when running cosmos_web_socket_example.py with COSMOS Open Source.
To Reproduce
Traceback (most recent call last):
File "c:\Users\...\cosmos_web_socket_example.py", line 24, in <module>
with StreamingWebSocketApi() as api:
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 62, in __exit__
self.disconnect()
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 153, in disconnect
self.unsubscribe()
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\script\web_socket_api.py", line 110, in unsubscribe
self.stream.write(json.dumps(json_hash))
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\openc3\streams\web_socket_client_stream.py", line 50, in write
self.connection.send(data)
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\websockets\sync\connection.py", line 281, in send
with self.send_context():
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages\websockets\sync\connection.py", line 715, in send_context
raise self.protocol.close_exc from original_exc
websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)
final_url = self.url + f"?scope={self.scope}&authorization={self.authentication.token()[7:]}"
to
final_url = self.url + f"?scope={self.scope}&authorization={self.authentication.token()}"
Environment
The text was updated successfully, but these errors were encountered: