Is Visual Studio's Browser Link feature able to use web sockets?

梦想与她 提交于 2019-12-18 05:48:31

问题


I understand that SignalR is used to communicate with client browsers using the injected artery script. I have what seems to be a common problem, which is that my browser's network log is filled with entries that look like this:

.../arterySignalR/poll?transport=longPolling&connectionToken=...

This tells me that SignalR has fallen back to long polling instead of using web sockets. Assuming that we have a browser that supports web sockets, and that browser is running on the localhost, shouldn't SignalR default to using web sockets? What might cause it to fall back to long polling?


回答1:


Short answer

Browser Link will only use WebSockets on Windows 8 or Windows Server 2012

Longer answer

The following would explain the issue if you're using Visual Studio on Windows 7, Windows Vista or Windows Server 2008:

IIS (Express) depends on the .NET framework implementation in System.Net.WebSockets to handle WebSocket connections; as you can read in the link to MSDN, you simply don't get an actual implementation of the necessary classes when you install .NET 4.5 on Windows 7.

So in that case, the server can't agree to the client's request to change from standard HTTP to the WebSocket protocol, which forces the SignalR client to use one of the fallback options (in your case: long-polling).



来源:https://stackoverflow.com/questions/21553366/is-visual-studios-browser-link-feature-able-to-use-web-sockets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!