SignalR无法发送

时间:2014-11-04 16:34:51

标签: javascript c# signalr

似乎我可以成功连接到我的服务器,重新连接,重新连接和断开连接的事件正确触发客户端,如下所示:

$.connection.hub.reconnecting(function() { tryingToReconnect = true; NotifyReconnect(); });
$.connection.hub.reconnected(function() { tryingToReconnect = false; });
$.connection.hub.disconnected(function() { if(tryingToReconnect) { NotifyReconnect(); } });
$.connection.hub.start().done(function () {
console.log(chat.state);
console.log('Now connected, connection ID=' + chat.id);
Success=true;
chat.server.send("Test");
}).fail(function(){ alert("Failed to connect."); });

我收到以下消息

Object {}
Now connected, connection ID=undefined

对于发送我

Uncaught Error: SignalR: Connection must be started before data can be sent. Call .start() before .send() 

这很奇怪,因为似乎建立了连接,我在控制台中收到以下消息:

SignalR.Transports.TransportHeartBeat Information: 0 : Connection 8c5d12f8-a0a5-
4bbe-a36c-14e74ddfccbf is New.
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(8c5d12f8-a0a5-4bbe-
a36c-14e74ddfccbf)
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(8c5d12f8-a0a5-4bbe-
a36c-14e74ddfccbf)
...

虽然服务器到客户端和客户端到服务器都没有发送工作,但是OnConnected / OnDisconnected事件也不会激活客户端(虽然他们做客户端)导致此问题的原因是什么?

0 个答案:

没有答案