Python Forum
WebSocketBadStatusException: Handshake status 307
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebSocketBadStatusException: Handshake status 307
#3
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):
connection.start()
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('http://189.70.78.89/Signalr', session);
#get chat hub
chat = connection.register_hub('ChatHub')

#start a connection
loop = asyncio.get_event_loop()
loop.run_until_complete(
asyncio.gather(my_coroutine(connection,5))
)
loop.close()


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



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('http://189.70.78.89/Signalr');
            //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}",
                                      task.Exception.GetBaseException());
                } else {
                    Console.WriteLine("Connected");
                }

            }).Wait();
Regards
Susmitha
Reply


Messages In This Thread
RE: WebSocketBadStatusException: Handshake status 307 - by Susmitha - Apr-24-2017, 04:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  IBM Watson: Handshake status 403 Forbidden or No section: 'auth' groschat 1 2,800 May-07-2021, 03:44 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020