信号器,客户端说已连接但无法通过服务器进行通信

时间:2017-02-01 13:22:23

标签: c# sql-server websocket signalr signalr-backplane

我们有一个客户端和一个通过signalr进行通信的服务器。在客户端首次启动时,它可以通过信号器与服务器连接,并通过集线器与某些信号器方法通信。但是在一个特定事件之后,服务器无法通过信号器进行通信。但在客户端显示连接已连接。以下是与服务器连接后来自客户端的信号器跟踪日志。

9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: initialized)
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {"C":"s-0,C5FA","S":1,"M":[]})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"I":"93"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - ChangeState(Connecting, Connected)
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {"C":"s-0,C636","M":[{"H":"PrintConnectorHub","M":"Registered","A":[{"Connected":false,"ErrorCount":0,"InstalledBy":{"EmployeeId":1111,"Firstname":null,"Lastname":null},"Name":"*** ***","Server":{"ComputerName":"**","IPAddress":"****","MACAddress":"****","OperatingSystem":"Microsoft® Windows Server® 2008 Standard FE "},"Status":0,"Version":"1.4.4"}]}]})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"90"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - Callback with id 90 not found!
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"94"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"92"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - Callback with id 92 not found!
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {})

此后虽然客户端仍然是连接服务器,但无法通过信号器向客户端发送任何消息。我们在2个客户端和所有客户端信号器跟踪日志中都遇到了这个问题,它在连接被触发后显示了这些日志行。

9492fb51-e37b-4f6c-b184-536c87dd73f1 - SSE: OnMessage(Data: {"C":"s-0,C636","M":[{"H":"PrintConnectorHub","M":"Registered","A":[{"Connected":false,"ErrorCount":0,"InstalledBy":{"EmployeeId":1111,"Firstname":null,"Lastname":null},"Name":"*** ***","Server":{"ComputerName":"**","IPAddress":"****","MACAddress":"****","OperatingSystem":"Microsoft® Windows Server® 2008 Standard FE "},"Status":0,"Version":"1.4.4"}]}]})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"90"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - Callback with id 90 not found!
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"94"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - OnMessage({"R":false,"I":"92"})
9492fb51-e37b-4f6c-b184-536c87dd73f1 - Callback with id 92 not found!

41889ccd-5634-440a-95ef-fbbdcd340a19 - SSE: OnMessage(Data: {"C":"s-0,C634","M":[{"H":"PrintConnectorHub","M":"Registered","A":[{"Connected":false,"ErrorCount":0,"InstalledBy":{"EmployeeId":1111,"Firstname":null,"Lastname":null},"Name":"***","Server":{"ComputerName":"****","IPAddress":"****","MACAddress":"****","OperatingSystem":"Microsoft Windows Server 2008 R2 Standard "},"Status":0,"Version":"1.3.8"}]}]})
41889ccd-5634-440a-95ef-fbbdcd340a19 - SSE: OnMessage(Data: {})
41889ccd-5634-440a-95ef-fbbdcd340a19 - OnMessage({"R":false,"I":"611"})
41889ccd-5634-440a-95ef-fbbdcd340a19 - Callback with id 611 not found!
41889ccd-5634-440a-95ef-fbbdcd340a19 - OnMessage({"R":false,"I":"615"})
41889ccd-5634-440a-95ef-fbbdcd340a19 - OnMessage({"R":false,"I":"613"})
41889ccd-5634-440a-95ef-fbbdcd340a19 - Callback with id 613 not found!

我们正在使用SQl服务器的scaleout和SQL Server中的背板设置。在上面的日志中跟踪了什么,找不到id的回调意味着什么可能是服务器无法与客户端通信的问题,即使客户端日志显示为已连接?

1 个答案:

答案 0 :(得分:1)

  

找不到ID为613的回调!   找不到ID为611的回调!

它说它在Hub上找不到合适的方法。 您是否检查过您在正确的集线器上调用正确的方法名称?

你可以检查调用方法和args这样做:
定义管道模块

public class MyPipelineModule : HubPipelineModule
{
    protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
    {
        //context.Args
        //context.Hub
        //context.MethodDescriptor.Name
        return base.OnBeforeIncoming(context);
    }
}

在您配置SignalR的地方:

GlobalHost.HubPipeline.AddModule(new MyPipelineModule());