Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 WebSocketBadStatusException: Handshake status 307
I am trying to connect to a SignalR hub from python client using "signalr-client-0.0.7".In connection.start() its giving "WebSocketBadStatusException: Handshake status 307".The hub hosted in a remote machine , am using the IP of the server to connect to the hub.
***Please find the callstack
Traceback (most recent call last):
  File "d:\", line 16, in <module>
  File "D:\Python35-32\lib\site-packages\signalr_client-0.0.7-py3.5.egg\signalr\", line 50, in start
  File "D:\Python35-32\lib\site-packages\signalr_client-0.0.7-py3.5.egg\signalr\
transports\", line 28, in start
  File "D:\Python35-32\lib\site-packages\signalr_client-0.0.7-py3.5.egg\signalr\
transports\", line 38, in start
  File "D:\Python35-32\lib\site-packages\websocket_client-0.40.0-py3.5.egg\webso
cket\", line 487, in create_connection
    websock.connect(url, **options)
  File "D:\Python35-32\lib\site-packages\websocket_client-0.40.0-py3.5.egg\webso
cket\", line 214, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "D:\Python35-32\lib\site-packages\websocket_client-0.40.0-py3.5.egg\webso
cket\", line 65, in handshake
    status, resp = _get_resp_headers(sock)
  File "D:\Python35-32\lib\site-packages\websocket_client-0.40.0-py3.5.egg\webso
cket\", line 122, in _get_resp_headers
    raise WebSocketBadStatusException("Handshake status %d", status)
websocket._exceptions.WebSocketBadStatusException: Handshake status 307***
Am not able to find out why this error is hppening and what this 307 status code corresponds to? Could anyone faced the same issue ? Please share your insights on the issue.
Thanks in advance Susmitha
HI Larz60+ ,

Thanks for your reply.
In the server side on IIS I enabled URL redirection.
I checked the logs on IIS where the first status is 307 then  200 success status.But here as there is no wait while connecting to the hub the first status 307 is returning back I think.
And I wrote a C# client for the same and its able to reach the signalr hub and the connection is establishing.In this case also in the logs i can see the status is first 307 then 200.
So i dont think i have to do anything on the server side.
I tried to use async and await in my scripts to wait till it connect but could not succeed(first time am using this and am new to Python).
I used asyncio python module .
below is my python client code:

Quote:from requests import Session
from signalr import Connection
import asyncio

async def my_coroutine(connection,seconds_to_sleep):
await asyncio.sleep(seconds_to_sleep)

with Session() as session:
# Used to turn off certificate verification, without this you will get a SSLError
session.verify = False;

#create a connection
connection = Connection('', session);
#get chat hub
chat = connection.register_hub('ChatHub')

#start a connection
loop = asyncio.get_event_loop()

#start connection, optionally can be connection.start()
with connection:
while True:
#wait a second before exit

Could you please tell what is wrong here.My intention is to write the script similar to the C# cde below.

Quote:var connection = new HubConnection('');
            //Make proxy to hub based on hub name on server
            var myHub = connection.CreateHubProxy("ChatHub");
            //Start connection

            connection.Start().ContinueWith(task => {
                if (task.IsFaulted) {
                    Console.WriteLine("There was an error opening the connection:{0}",
                } else {


Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)