SignalR Native Host: A connection must be started before data is sent. Call .start () before .send ()

I know this is another post related to this problem :)

I am trying to rewrite my project to use the SignalR Self-Host library (according to this tutorial), but cannot get this error now.

I initialize the connection as follows:

$.connection.hub.url = "http://localhost:8182/signalr";
$.connection.hub.logging = true;
var connection = $.connection.hub.start();

console.log(connection.state());

connection.done(function () {
    console.log(connection.state());
    [...] // initialising viewmodels in here...
});

When the first view model is initialized, I get an error depending on the topic topic:

[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Auto detected cross domain url. jquery.signalR-2.0.3.js:76
[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Negotiating with 'http://localhost:8182/signalr/negotiate?clientProtocol=1.3'. jquery.signalR-2.0.3.js:76
pending main.js:218
[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Attempting to connect to SSE endpoint 'http://localhost:8182/signalr/connect?transport=serverSentEvents&connection…pdQlpKjRBpUhB0PY4itVfHasSmixQAAAB0HA7hA9gYDflrhGockG%2FZR55tLg%3D%3D&tid=1'. jquery.signalR-2.0.3.js:76
[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: EventSource connected. jquery.signalR-2.0.3.js:76
[17:29:14 GMT+0100 (GMT Daylight Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000. jquery.signalR-2.0.3.js:76
resolved main.js:220
Object {getAccountActions: function, getIncidentActionCount: function, getIncidentActions: function, refreshAccountActions: function, refreshActions: function…}
 IncidentAction.js:12
Uncaught Error: SignalR: Connection must be started before data can be sent. Call .start() before .send() 

The console connection status is console.log after connection.done and is clearly displayed as allowed.

Also in the first view model I initialize, I console.log connection.server and all my server methods are visible there, according to the above snippet.

Server Side Code:

class Program
    {
        static void Main(string[] args)
        {
            string url = "http://localhost:8182";
            using (WebApp.Start(url))
            {
                Console.WriteLine("Server running on {0}", url);
                Console.ReadLine();
            }
        }
    }

, , ""?

: Owin , , . signalR,

+4
1

:

 $.connection.hub.start().done(function () {
         console.log(connection.state());
     })  .fail(function (error) {
         console.log('Invocation of start failed. Error:'+ error)
     });
+1

Source: https://habr.com/ru/post/1538448/


All Articles