There is a lot of “connection that needs to be started before data can be sent” here and on GitHub, but I hardly see any problems with hubs.
$(function () { // Declare a proxy to reference the hub. var connection = $.hubConnection('http://www.website.net/'); var chat = connection.createHubProxy('MyHub'); // Start the connection. $.connection.hub.start().done(function () { console.log('Connect! connection Id=' + $.connection.hub.id); $('#sendmessage').click(function () { chat.invoke('method1','0000').done(function () { console.log ('Invocation of method1 succeeded'); }).fail(function (error) { console.log('Invocation of method1 failed. Error: ' + error); }); }); }) .fail(function(){ console.log('Could not Connect!'); }); });
The above code makes it possible to execute the method when the user clicks a button. I can check if this method works with my WPF.NET application.
I can get the connection identifier successfully, but when I click the button, it says “SignalR call method: the connection must be started before sending data. Call .start () before the .send () error.
What did I misunderstand?
javascript signalr
Youngjae
source share