Safari AJAX错误-无法加载资源 [英] Safari AJAX bug - Failed to load resource

查看:76
本文介绍了Safari AJAX错误-无法加载资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从今天开始,我在一个正在处理的Web应用程序中遇到一个非常奇怪的错误.我没有对代码做任何事情,从一天到一天,这个错误出现了:

since today I have a pretty strange bug in an web app I'm working on. I haven't done anything to the code and from one day to another this bug appeared:

我向运行MAMP PRO的本地服务器执行AJAX请求(不是使用jquery,而是使用普通的js).在chrome和firefox中都可以正常工作(在Mac上测试).但是在野生动物园中,请求始终会引发错误:无法加载资源:网络连接丢失

I execute AJAX requests (not with jquery but with normal js) to our local server running MAMP PRO. All works fine in chrome and firefox (testing on a mac). But in safari the request always throws an error: Failed to load resource: the network connection was lost

当我尝试手动加载请求的网址(而不是通过AJAX)时,一切正常.我还使用 setTimeout 测试了请求,发现了一些有趣的东西:

When I try to load the url of the request manually (not via AJAX) everything works fine. I also tested the request with a setTimeout and found something interesting:

当我在页面加载(不超过60毫秒)后直接执行请求时,一切正常.之后,连接会偶尔丢失,直到6000毫秒为止,一切恢复正常!相当奇怪的行为...我不与任何其他setTimeouts一起工作,所以该问题只能由野生动物园引起.

When I do the request directly after page load (up to 60 millisecs) all works fine. After that the connection is lost sporadicly till 6000 milliseconds where everything works fine again! Pretty strange behaviour... I'm not working with any other setTimeouts so the problem can only be caused by safari.

我做错什么了吗,或者这只是一个非常新的野生动物园错误?

Am I doing something wrong or is this just a very new safari bug?

推荐答案

在为我们的Web应用程序开发大型新功能时,我们也遇到了这个问题.我们使用来自JS客户端的XHR请求从Amazon Linux上托管的Tomcat服务器获取用户收藏夹.初始连接按预期工作正常.但是,第二个相同的请求在客户端JS控制台中失败,并显示无法加载资源:网络连接丢失".我怀疑Safari将第二个请求识别为第一个请求的错误副本.

In developing a large new feature for our web app, we ran into this problem as well. We use an XHR request from the JS client to get user favorites from the Tomcat server hosted on Amazon Linux. The initial connection works fine as expected. However, the second identical request fails with "Failed to load resource: the network connection was lost" in the client JS console. I suspect Safari recognizes the second request as a mistaken duplicate of the first.

我们当前用于Tomcat的解决方法是有效地禁用KeepAlive支持.不幸的是,这会影响所有连接,不仅影响台式机和/或移动设备上的Safari.Tomcat的此解决方案是在$ {CATALINA_HOME}/conf/server.xml ...

The current workaround we are using for Tomcat is to effectively disable KeepAlive support. Unfortunately, this affects all connections, not just for Safari on desktop and/or mobile. This solution for Tomcat is to set a parameter on the Connector for HTTPS in ${CATALINA_HOME}/conf/server.xml...

maxKeepAliveRequests="1"

可能还有其他解决方案可以将损坏仅限于Safari连接.如果发现它们,我会回来更新此帖子.更好的乐队帮助是将结果缓存到我们的应用程序中,从而完全避免出现问题.

There might be other solutions to limit the damage to only Safari connections. If I discover them, I'll come back and update this post. The better band aid would be to cache results in our app and avoid the problem altogether.

这篇关于Safari AJAX错误-无法加载资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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