I have a SignlaR server in ASP .NET Core 2.0 application hosted in Windows AZURE:
public class Chat : Hub
{
public Task Send(string message)
{
return Clients.All.InvokeAsync("Send", message);
}
}
I also have client in Javascript:
<script src="scripts/signalr-client.min.js"></script>
connection.on('send', data => {
console.log(data);
});
connection.start()
.then(() => connection.invoke('send', 'Hello'));
It works fine but how to connect this server in Python Script? There is the library: https://pypi.python.org/pypi/signalr-client/0.0.6
But doesn't work. I have an error:
signalr/negotiate 404 (not found)
Python code:
from requests import Session
from signalr import Connection
with Session() as session:
#create a connection
connection = Connection("wss://wg2.azurewebsites.net", session)
#get chat hub
chat = connection.register_hub("deviceshub")
#start a connection
connection.start()
Can you provide a working sample (Python client) with ASP .NET Core 2.0?
The python library you are using seems to be for the previous version of SignalR. SignalR for Asp.NET Core is not compatible with the previous version of SignalR so the old client will not work with the new server (or vice versa).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With