This article is a mirror article of machine translation, please click here to jump to the original article.

View: 30231|Reply: 1

[Source] SignalR does not use the websocket protocol to communicate

[Copy link]
Posted on 4/18/2019 5:33:48 PM | | | |
ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to their applications. A real-time web feature is a feature where server code can push content to a connected client as soon as it becomes available, rather than having the server wait for the client to request new data.

ASP .NET SignalR is a class library under ASP .NET, which can realize real-time communication in ASP .NET web projects (that is, the client (web page) and the server side can notify each other in real time and call methods), SignalR has three transmission modes: LongLooping (long polling), WebSocket (HTML5 WEB socket), Forever Frame ( long request connections that hide the frame), can be explicitly specified in the WEB client or by default (recommended), if the default is adopted,SignalR will automatically select the appropriate transmission method based on the browser's environment

Because the website data loading is too slow, the reason is that the data packet is too large, and the network request is suitable, and it is found that "ws" is empty, and then it is found that SignalR does not use the websocket protocol.

When I debugged locally, I found that the website can use the WS protocol normally, that is, it can communicate normally with websockets, and then observe the difference between server and local network requests, and found that it is as follows:



URL:http://ip/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22positionvehiclehub%22%7D%5D&_=1555578162378

Local:

{"Url":"/signalr","ConnectionToken":"iX0gmz3XDJpQ62b6eiWK16Quaf+LFlD5aHw1k2oC6dKPz7naDuFmc0M7+xiR72ZjJDuNnMvfZyZF72qJK/4g6FOKAsY5C0uCfViOBXPRJVMBczOXTyCKcztIcugmcBq8" ,"ConnectionId":"50598ad3-b138-458c-a58d-b4f84d23c0e0","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true," ProtocolVersion":"1.5","TransportConnectTimeout":5.0,"LongPollDelay":0.0}
Servers:

{"Url":"/signalr","ConnectionToken":"4JbNUOp5/ju8Fljn29tCsFoTitZXk3XfF3tkuc/OYpaEQPawJHi3U1nTtjcJJzK4mVsOn9nAEECZj7h5732aV7tNJDgsasCon9uQwhqXZC5EAZPrAgASueApAjBCpPpE" ,"ConnectionId":"c46e67b1-4fb4-4345-983f-bf2c391d33e0","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":false," ProtocolVersion":"1.5","TransportConnectTimeout":5.0,"LongPollDelay":0.0}
Some parameters are originally different from the local and server ones, and I found itTryWebSocketsparameter, local is true, server is false.



Looking at the information, it is found that if SignalR uses the WebSocket protocol, the following conditions need to be met:

  • ASP.NET 4.5
  • IIS 8.0 (Windows Server 2012 or Windows 8)
  • WebSockets feature is enabled on the server
  • Support for browser WebSockets



This is, I found that the IIS version on the server is 7.5,The WebSocket protocol is not supported in IIS 7.5



Reference links:The hyperlink login is visible.




Previous:WPF Programmer Rest Digital Clock [with source code]
Next:"Crazy Programmer"
Posted on 4/22/2019 9:24:01 AM |
Good things Mark
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com