Signalr 信号器(原始)不向客户端发送消息

Signalr 信号器(原始)不向客户端发送消息,signalr,nservicebus,Signalr,Nservicebus,我们正在使用SignalR(原始版本,而不是核心版本),并注意到一些令人费解的行为。我们的情况如下: 我们有一个通过GenericCommand()方法接受命令的中心(见下文) 这些命令使用NServiceBus放置在messagebus上 命令的执行产生一个事件 事件的处理程序将生成一条发送到所有SignalR客户端的消息(见下文) 使用Chrome中的调试器工具查看Websocket消息,很明显,有时(但并非总是)不会将“InvokeToAll”消息发送到任何客户端。不会抛出错误,所有已连接

我们正在使用SignalR(原始版本,而不是核心版本),并注意到一些令人费解的行为。我们的情况如下:

  • 我们有一个通过GenericCommand()方法接受命令的中心(见下文)
  • 这些命令使用NServiceBus放置在messagebus上
  • 命令的执行产生一个事件
  • 事件的处理程序将生成一条发送到所有SignalR客户端的消息(见下文)
  • 使用Chrome中的调试器工具查看Websocket消息,很明显,有时(但并非总是)不会将“InvokeToAll”消息发送到任何客户端。不会抛出错误,所有已连接的客户端只发送心跳信号,指示它们仍在连接

    此外,服务器上的跟踪(见下文)日志表明连接在整个时间内都处于活动状态,但出于某种原因,从集线器立即发送的三条测试“已接收”消息被发送回客户端,但从事件处理程序发送的结果“InvokeToAll”出于某种原因没有使用Websocket发送。我们知道调用事件处理程序是因为
    \u notificationService.MarkAsDone()
    调用会在数据库中留下跟踪,确认调用了它

    我们注意到的最后一件事是,这个设置一直工作到它不工作为止。一旦消息停止发送到客户机,所有客户机的消息将始终停止。我们完全不知道可能会发生什么,或者我们还能做些什么来进一步调试它。没有错误被抛出,工作的东西只是突然停止工作而没有通知

    任何帮助或指点都将不胜感激

    以下是集线器的代码(步骤1):
    公共异步任务GenericCommand(GenericEventData数据){
    等待_messageBus.PublishEvent(新的GenericSignalrCommandReceivedEvent{
    CorrelationId=Guid.Parse(data.CorrelationId),
    Command=data.Command,
    DataJson=data.DataJson,
    ConnectionId=Context.ConnectionId
    });
    //添加用于调试目的
    var ctx=GlobalHost.ConnectionManager.GetHubContext();
    IClientProxy代理=ctx.Clients.Client(Context.ConnectionId);
    wait proxy.Invoke(data.CorrelationId,“Received-ConnectionId”);
    proxy=ctx.Clients.User(Context.User.Identity.Name);
    wait proxy.Invoke(data.CorrelationId,“Received-Clients.User”);
    proxy=ctx.Clients.Group(“JCUSER:+Context.User.Identity.Name”);
    wait proxy.Invoke(data.CorrelationId,“Received-Clients.Group”);
    }
    
    下面是事件处理程序的代码(步骤4)
    专用异步任务ReplyViaSignalR(信号完成数据,IMessageHandlerContext){
    var ctx=GlobalHost.ConnectionManager.GetHubContext();
    var proxy=ctx.Clients.All;
    等待proxy.Invoke(“InvokeToAll”,“Yay message received!”);
    wait_notificationService.MarkAsDone(数据);
    }
    
    以下是服务器上用于连接此客户端的跟踪日志的摘录:
    事实证明,这个问题是由于我们在同一个应用程序池中有多个站点使用不同的主机名指向同一目录造成的

    这导致应用程序运行此站点的多个并发实例,尽管只显示了一个w3wp.exe进程(这是我们为了消除多个实例同时运行的可能性而研究的)

    我们计划在有机会的时候,通过简单地将绑定组合到同一个网站实例来改变这种情况。我完全预料到问题届时会得到解决

    SignalR.Transports.TransportHeartBeat Information: 0 : Connection 1d603a67-1161-4a27-82f0-9046ec73cd60 is New.
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"C":"d-498F7600-B,15|rS,0|pP,A|rT,1","S":1,"M":[]}
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"C":"d-498F7600-B,15|rS,0|pP,A|rT,2|pR,1E","G":"F2q+KKxufchVxQUnH9leeyYR6fGPfHYRCIQW55XZbNEbbibRlbVYld/b0fzihC34VrDwmoaNy2uTJYnRCeQO9zGEoqNk+9qbAi72dPep52CgpicyPGQOlvNzUOlNK1v2j34SdPXHI8DwpDwx/7SA317XJMJPxrCE5Qsgt/kgTzE=","M":[]}
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"C":"d-498F7600-B,1F|rS,5|pP,19|rT,2|pR,43","M":[{"H":"EventHub","M":"a1ec2fa6-f33c-4161-9166-07ee64558be1","A":["Received - ConnectionId"]},{"H":"EventHub","M":"a1ec2fa6-f33c-4161-9166-07ee64558be1","A":["Received - Clients.User"]}]}
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"C":"d-498F7600-B,1F|rS,5|pP,19|rT,2|pR,44","M":[{"H":"EventHub","M":"a1ec2fa6-f33c-4161-9166-07ee64558be1","A":["Received - Clients.Group"]}]}
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"I":"4"}
    SignalR.Transports.WebSocketTransport Verbose: 0 : Sending outgoing message. Connection id: 1d603a67-1161-4a27-82f0-9046ec73cd60, transport: WebSocketTransport, message: {"C":"d-498F7600-B,1F|rS,5|pP,19|rT,2|pR,45","M":[]}
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1d603a67-1161-4a27-82f0-9046ec73cd60)