Description
I have the following code
`
from scratchclient import ScratchSession
import time
USERNAME = "username"
PASSWORD = "password"
PROJECT_ID = "project_id"
print("Logging in...")
session = ScratchSession(USERNAME, PASSWORD)
print("Logged in successfully.")
print("Connecting to cloud variables...")
try:
conn = session.create_cloud_connection(PROJECT_ID)
print("Connection established!")
except Exception as e:
print(f"Error establishing connection: {e}")
exit(1)
def on_update(variable_name, value):
print(f"Cloud variable {variable_name} updated: {value}")
conn.add_listener(on_update)
while True:
time.sleep(1)
`
But when i run it it causes this Error:
Traceback (most recent call last): File "D:\coding\tbw\sc test\backend.py", line 5, in connection = session.create_cloud_connection(1153518260) File "C:\Users\ich\AppData\Local\Programs\Python\Python310\lib\site-packages\scratchclient\ScratchSession.py", line 170, in create_cloud_connection else CloudConnection(project_id, self, cloud_host, headers) File "C:\Users\ich\AppData\Local\Programs\Python\Python310\lib\site-packages\scratchclient\CloudConnection.py", line 90, in init self.connect(headers) File "C:\Users\ich\AppData\Local\Programs\Python\Python310\lib\site-packages\scratchclient\CloudConnection.py", line 108, in connect self._ws.connect( File "C:\Users\ich\AppData\Local\Programs\Python\Python310\lib\site-packages\scratchclient\Websocket.py", line 159, in connect self.handshake(parsed_url, headers, secure) File "C:\Users\ich\AppData\Local\Programs\Python\Python310\lib\site-packages\scratchclient\Websocket.py", line 199, in handshake raise WebsocketException("Handshake failed") scratchclient.Websocket.WebsocketException: Handshake failed