I was trying to make a socket connection from my python script to my server. I create a basic connection script (in below) and succesfuly make a connection to Windows Server 2016 (ISS version: 10.0.14393.0) . But when I try same script on Windows Server 2019 (ISS version 10.0.17763.1) I got this error:
Handshake status 400 Bad Request class 'websocket._exceptions.WebSocketBadStatusException' ERROR:SignalRCoreClient:Handshake status 400 Bad Request class 'websocket._exceptions.WebSocketBadStatusException'
What could cause this problem?
Python script:
from signalrcore.hub_connection_builder import HubConnectionBuilder
socket_url = 'ws://mysocketurl.com'
def myprint(msg):
print(msg)
pass
try:
print("Starting Connection...")
hub_connection = HubConnectionBuilder()\
.with_url(socket_url,
options={
"headers": {
"DeviceID": '123123'
}
})\
.with_automatic_reconnect({
"type": "raw",
"keep_alive_interval": -1,
"reconnect_interval": 5
}).build()
hub_connection.on("Connected", myprint)
hub_connection.start()
except Exception as exc:
print("Socket stop working. Error:")
hub_connection.stop()
From Server Protocol list you would have to add WebSocket Protocol and install it. After this update it worked.