简体   繁体   English

使用服务器发送的事件时浏览器限制连接

[英]Browser limit connections when using server-sent events

I'm using Server Sent Events in my web application and have 2 persistent connections on every page for real time notifications from the server. 我在Web应用程序中使用“服务器发送事件”,并且每个页面上都有2个持久连接,用于从服务器实时通知。 I faced a problem where browsers limit concurrent connections to the same domain (eg FF limit is 6) so when user will open few pages, next connection will be queued by browser and the page will freeze. 我遇到了一个问题,浏览器将并发连接限制到同一域(例如FF限制为6),因此当用户打开几个页面时,下一个连接将被浏览器排队,并且页面将冻结。

This is killing all advantage of SSE vs simple polling. 与简单轮询相比,这扼杀了SSE的所有优势。

Is there any workaround except make SSE connection via some subdomain to not freeze main domain connections? 除了通过某些子域进行SSE连接以不冻结主域连接之外,是否有其他解决方法?

I've answered this question here . 我已经在这里回答了这个问题。

That is due to the maximum number of connections of the browser to a single domain. 那是由于浏览器到单个域的最大连接数。

What you could do is collect all Deferred objects and cancel them when the use clicks on a link. 您可以做的是收集所有Deferred对象,并在使用单击链接时将其取消。

See answer for more details. 请参阅答案以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM