Sant14
Sant14

Reputation: 300

Signalr Exception in Browser

I am trying to create a chat application but after successful build of the web app its catching an exception when i am passing the paramaters for chat.The exception is

0x800a139e - JavaScript runtime error: SignalR: Connection must be started before data can be sent. Call .start() before .send()

The screen shots are attached here enter image description here

enter image description here

Upvotes: 0

Views: 383

Answers (1)

halter73
halter73

Reputation: 15244

You need to make sure you don't try invoking server-side hub methods until start is done. Ex:

$.connection.hub.start().done(function(){
     $('#submit').click(function () {
         $.connection.chat.server.addMessage($('#msg').val());
     })
});

Notice that the event handler isn't wired up until the connection is established.

Upvotes: 1

Related Questions