Skip to content

Commit

Permalink
Fix "Sec-WebSocket-Key" length issue for streaming_ping (#869)
Browse files Browse the repository at this point in the history
The actual response from the `response.text` is: Can't establish socket connection: websocket: not a websocket handshake: 'Sec-WebSocket-Key' header must be Base64 encoded value of 16-byte in length
  • Loading branch information
LeonBitCraft authored Aug 18, 2024
1 parent a49c152 commit ab92ced
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion run/tesla_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def streaming_ping():
'Authorization': 'Bearer {}'.format(_get_api_token()),
'Connection': 'Upgrade',
'Upgrade': 'websocket',
'Sec-WebSocket-Key': base64.b64encode(bytes([random.randrange(0, 256) for _ in range(0, 13)])).decode('utf-8'),
'Sec-WebSocket-Key': base64.b64encode(bytes([random.randrange(0, 256) for _ in range(0, 16)])).decode('utf-8'),
'Sec-WebSocket-Version': '13',
}

Expand Down

0 comments on commit ab92ced

Please sign in to comment.