DEV Community

Discussion on: SignalR core python client: A simple Chat Hub Client

Collapse
 
akanaan profile image
a-kanaan

any idea why I am receving handshake error

DEBUG:SignalRCoreClient:-- web socket error --
Handshake status 400 Bad Request
ERROR:SignalRCoreClient:Handshake status 400 Bad Request

server_url = input_with_default('Enter your server url(default: {0}): ', "ws://mypc.domin.com:4500/faces")

'faces' is the hub name
endpoints.MapHub("faces");

without 'faces' it returns OK

thank you

Collapse
 
mandrewcito profile image
Andrés Baamonde Lozano

Hi,

When you connect to a websocket. Previously, you negotiated the connection at mypc.domin.com:4500/faces/negotiate with a POST request. The response of that request will result a connection id that is passed on querystring of the ws://mypc.domin.com:4500/faces request.

If you are not sure that you are connecting to your hub. Try to override on your hub the following method:

public override async Task OnConnectedAsync ()

Collapse
 
akanaan profile image
a-kanaan

thank you Andrés Baamonde Lozano for your reply

curl -XPOST mypc.domain.com:4500/faces/negotiate -H 'Content-Length:0'
{"connectionId":"4Qwmg1Q1jsGN-5-gGpmbPw","availableTransports":[{"transport":"ServerSentEvents","transferFormats":["Text"]},{"transport":"LongPolling","transferFormats":["Text","Binary"]}]}

but I am when using the sample code to have python code connected to the Hub I am getting the following error:
DEBUG:SignalRCoreClient:Handler registered started broadcast
DEBUG:SignalRCoreClient:Connection started
DEBUG:root:start url:ws://mypc.domain.com:4500/faces
DEBUG:SignalRCoreClient:-- web socket error --
Handshake status 400 Bad Request
ERROR:SignalRCoreClient:Handshake status 400 Bad Request
DEBUG:SignalRCoreClient:-- web socket close --

any idea please if I have missed something?

Collapse
 
akanaan profile image
a-kanaan

all the time I was testing using IIS hosted hub, but I tested now running from Visual Studio, and I got my python code working fetching the info from the hub. the issue seems related to IIS. when testing again using IIS hub, I am getting again the handshake error