Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP .NET Core 2.0, SignalR

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?

like image 369
Norbert Pisz Avatar asked Feb 15 '18 10:02

Norbert Pisz


1 Answers

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).

like image 152
Pawel Avatar answered Sep 19 '22 22:09

Pawel