Windows Server 2008R2 上的 SignalR 客户端使用服务器发送的事件
SignalR client on Windows Server 2008R2 using Server Sent Events
服务器: Windows 支持 WebSocket 的 Server 2012
客户端机器 1: Windows 8.1
客户端机器 2: Windows 服务器 2008R2
我使用 SigalR 客户端构建了一个 C# 应用程序,我可以在我的两台客户端计算机上部署它。但是,我 运行 遇到的问题是 Client Machine 1
使用 WebSockets 连接,Client Machine 2
使用服务器端事件连接。
怎么会这样呢?很明显,服务器支持 WebSockets,因为 Client Machine 1
可以使用它们进行连接。我不明白 Client Machine 2
如何使用 SSE。
在我的客户端上使用 hub.TraceLevel = TraceLevels.All;
,我看到:
20:57:01.5805156 - null - ChangeState(Disconnected, Connecting)
20:57:02.1117656 - 7ff6f37a-2485-4f08-9c20-872f63964bee - WS Connecting to: wss://internal.soroco.com/signalr/connect?clientProtocol=1.4&transport=webSockets&connectionData=[{"Name":"ClientDaemonHub"}]&connectionToken=Mvbkw1czN7OZSE1jcfFjC2elxYxJhZiTZwisKKn6ZzYv%2BXRjOgfkclRJdSQtPi2wy%2F7XsUyxbCEXPMesFjvE7zh0FrcGwEsh6WTpHlkqB0rXyARnC42Op8ZO3w%2FhuKcB
20:57:02.1273906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - Auto: Failed to connect to using transport webSockets. System.PlatformNotSupportedException: The WebSocket protocol is not supported on this platform.
at System.Net.WebSockets.ClientWebSocket..ctor()
at Microsoft.AspNet.SignalR.Client.Transports.WebSocketTransport.<PerformConnect>d__1.MoveNext()
20:57:02.1273906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: GET https://internal.soroco.com/signalr/connect?clientProtocol=1.4&transport=serverSentEvents&connectionData=[{"Name":"ClientDaemonHub"}]&connectionToken=Mvbkw1czN7OZSE1jcfFjC2elxYxJhZiTZwisKKn6ZzYv%2BXRjOgfkclRJdSQtPi2wy%2F7XsUyxbCEXPMesFjvE7zh0FrcGwEsh6WTpHlkqB0rXyARnC42Op8ZO3w%2FhuKcB
20:57:02.1430156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: initialized)
20:57:02.1430156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: {"C":"d-752B7883-B,0|I,0|J,1","S":1,"M":[]})
20:57:02.4086406 - 7ff6f37a-2485-4f08-9c20-872f63964bee - ChangeState(Connecting, Connected)
20:57:03.5180156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"R":"497ca302-7375-4250-aa85-fb4ae2556877","I":"0"})
20:57:03.8461406 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"1"})
20:57:04.7523906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: {})
20:57:05.7523906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"2"})
20:57:07.7367656 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"3"})
看起来相关的错误是:
Auto: Failed to connect to using transport webSockets. System.PlatformNotSupportedException: The WebSocket protocol is not supported on this platform.
Win7 和 Win2008 R2 上的 NET Framework 4.5 doesn't support the ClientWebSocket
class,这就是 SignalR 客户端用于 websocket 传输的内容。由于使用 websocket 失败,客户端回退到 ServerSentEvents。
服务器: Windows 支持 WebSocket 的 Server 2012
客户端机器 1: Windows 8.1
客户端机器 2: Windows 服务器 2008R2
我使用 SigalR 客户端构建了一个 C# 应用程序,我可以在我的两台客户端计算机上部署它。但是,我 运行 遇到的问题是 Client Machine 1
使用 WebSockets 连接,Client Machine 2
使用服务器端事件连接。
怎么会这样呢?很明显,服务器支持 WebSockets,因为 Client Machine 1
可以使用它们进行连接。我不明白 Client Machine 2
如何使用 SSE。
在我的客户端上使用 hub.TraceLevel = TraceLevels.All;
,我看到:
20:57:01.5805156 - null - ChangeState(Disconnected, Connecting)
20:57:02.1117656 - 7ff6f37a-2485-4f08-9c20-872f63964bee - WS Connecting to: wss://internal.soroco.com/signalr/connect?clientProtocol=1.4&transport=webSockets&connectionData=[{"Name":"ClientDaemonHub"}]&connectionToken=Mvbkw1czN7OZSE1jcfFjC2elxYxJhZiTZwisKKn6ZzYv%2BXRjOgfkclRJdSQtPi2wy%2F7XsUyxbCEXPMesFjvE7zh0FrcGwEsh6WTpHlkqB0rXyARnC42Op8ZO3w%2FhuKcB
20:57:02.1273906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - Auto: Failed to connect to using transport webSockets. System.PlatformNotSupportedException: The WebSocket protocol is not supported on this platform.
at System.Net.WebSockets.ClientWebSocket..ctor()
at Microsoft.AspNet.SignalR.Client.Transports.WebSocketTransport.<PerformConnect>d__1.MoveNext()
20:57:02.1273906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: GET https://internal.soroco.com/signalr/connect?clientProtocol=1.4&transport=serverSentEvents&connectionData=[{"Name":"ClientDaemonHub"}]&connectionToken=Mvbkw1czN7OZSE1jcfFjC2elxYxJhZiTZwisKKn6ZzYv%2BXRjOgfkclRJdSQtPi2wy%2F7XsUyxbCEXPMesFjvE7zh0FrcGwEsh6WTpHlkqB0rXyARnC42Op8ZO3w%2FhuKcB
20:57:02.1430156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: initialized)
20:57:02.1430156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: {"C":"d-752B7883-B,0|I,0|J,1","S":1,"M":[]})
20:57:02.4086406 - 7ff6f37a-2485-4f08-9c20-872f63964bee - ChangeState(Connecting, Connected)
20:57:03.5180156 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"R":"497ca302-7375-4250-aa85-fb4ae2556877","I":"0"})
20:57:03.8461406 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"1"})
20:57:04.7523906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - SSE: OnMessage(Data: {})
20:57:05.7523906 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"2"})
20:57:07.7367656 - 7ff6f37a-2485-4f08-9c20-872f63964bee - OnMessage({"I":"3"})
看起来相关的错误是:
Auto: Failed to connect to using transport webSockets. System.PlatformNotSupportedException: The WebSocket protocol is not supported on this platform.
Win7 和 Win2008 R2 上的 NET Framework 4.5 doesn't support the ClientWebSocket
class,这就是 SignalR 客户端用于 websocket 传输的内容。由于使用 websocket 失败,客户端回退到 ServerSentEvents。