Visual Studio的浏览器链接功能是否可以使用Web套接字? [英] Is Visual Studio's Browser Link feature able to use web sockets?

查看:90
本文介绍了Visual Studio的浏览器链接功能是否可以使用Web套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道SignalR用于使用注入的动脉脚本与客户端浏览器进行通信.我似乎有一个常见问题,那就是我的浏览器的网络日志中充满了如下所示的条目:

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 = ...

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

这告诉我SignalR已退回长时间轮询,而不是使用Web套接字.假设我们有一个支持Web套接字的浏览器,并且该浏览器正在localhost上运行,SignalR是否应该默认不使用Web套接字?是什么导致它退回长时间轮询?

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?

推荐答案

简短答案

浏览器链接将仅在Windows 8或Windows Server 2012上使用WebSockets

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

更长的答案

如果您在Windows 7,Windows Vista或Windows Server 2008上使用Visual Studio,以下内容将解释该问题:

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

IIS(Express)依赖于

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.

因此,在这种情况下,服务器无法同意客户端将标准HTTP更改为WebSocket协议的请求,这将迫使SignalR客户端使用一种后备选项(在您的情况下为长轮询).

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).

这篇关于Visual Studio的浏览器链接功能是否可以使用Web套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆