Javascript 跨域请求的间歇性 ERR_SSL_PROTOCOL_ERROR 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29891619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Intermittent ERR_SSL_PROTOCOL_ERROR error for cross domain request
提问by Harry Lime
The users of my website are seeing intermittent ERR_SSL_PROTOCOL_ERRORwhen making cross domain requests to api.flickr.com
我网站的用户ERR_SSL_PROTOCOL_ERROR在发出跨域请求时看到断断续续api.flickr.com
By intermittent I mean that I've seen this happen 4 times out of ~1200 requests to the api yesterday.
间歇性我的意思是我昨天在对 api 的大约 1200 个请求中看到这种情况发生了 4 次。
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR https://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=.....
My site is and AngularJS application running on Google App Engine and is exclusivley avalable on HTTPS.
我的网站是在 Google App Engine 上运行的 AngularJS 应用程序,并且在 HTTPS 上是独家可用的。
sslchecker shows that my site's certificate & certificate chainis installed correctly. Well, I think it looks ok!
sslchecker 显示我网站的证书和证书链已正确安装。嗯,我觉得还行!
sslchecker for api.flickr.comshows that ROOT 1of the certificate chain is missing. Is that the problem? Is there any way around that for me?
sslchecker forapi.flickr.com显示ROOT 1缺少证书链。这是问题吗?对我来说有什么办法吗?
Any other ideas? Is the problem that our certificates are issues by different authorities maybe?
还有其他想法吗?问题是我们的证书是不同机构颁发的吗?
Edit -Some other possibly relevant info gleaned from google analytics
编辑 -从谷歌分析收集的其他一些可能相关的信息
- Have seen it happen for different OSes - Android, iOS, Windows
- Different browsers - Android, Chrome, Safari
- Different Network Domains
- 已经看到它发生在不同的操作系统上 - Android、iOS、Windows
- 不同的浏览器 - Android、Chrome、Safari
- 不同的网域
采纳答案by Dave Alperovich
Persistent SSL Protocol Errorsmay be caused by problems like
持久性SSL 协议错误可能是由以下问题引起的
the destination server expects a different protocol (e.g. SSLv1, SSLv2, SSLv3)
a violation of a security policy (e.g. some servers don't honor certificate requests made from client)
Firewall impedance filtering / ciphering
目标服务器需要不同的协议(例如 SSLv1、SSLv2、SSLv3)
违反安全策略(例如,某些服务器不接受来自客户端的证书请求)
防火墙阻抗过滤/加密
Intermittent SSL Protocol Errorsare very hard to diagnose. They can be the result of expired session, expired key, connectivity hiccup, lost packets, etc
间歇性SSL 协议错误很难诊断。它们可能是会话过期、密钥过期、连接中断、数据包丢失等的结果
Even worse, they can be caused by Server Side issues like date-time sync, server connection pool full, etc.
更糟糕的是,它们可能是由服务器端问题引起的,例如日期时间同步、服务器连接池已满等。
Best practice is to re-send the request:because such issues are often a temporary glitch, and usually succeed at 2nd attempt.
最佳做法是重新发送请求:因为此类问题通常是暂时性故障,通常会在第二次尝试时成功。
Flickrswitched their API to SSL-only on June 27th, 2014(a little under a year). Their Forum has blown up with SSL related problems since then.
Flickr于2014年6 月 27 日(不到一年)将他们的 API 切换为仅 SSL。从那时起,他们的论坛就因与 SSL 相关的问题而炸毁。
In the past few months many users have reported (check thread) sporadic SSL Protocol Errors.
在过去的几个月中,许多用户报告(检查线程)零星的SSL 协议错误。
These Protocol Errorsappear across all device types (laptops, desktops, mobile, Linux, Windows, etc) and usually an immediate re-try is successful. The commonality and highly infrequent nature of these problems indicates there is some issue on the host side completely unrelated to anything on the client.
这些协议错误出现在所有设备类型(笔记本电脑、台式机、移动设备、Linux、Windows等)中,通常立即重试即可成功。这些问题的共性和非常罕见的性质表明主机端存在一些与客户端上的任何事情完全无关的问题。
Since a re-fresh or 2nd attempt is usually successful, I suggest trapping the error, and making 1-3 more attempts:
由于重新尝试或第二次尝试通常会成功,我建议捕获错误,然后再尝试 1-3 次:
var promise = flickrService.get(...);
promise.success(function (data, status, headers, config) {
// Big Party
})
.error(function(data, status, headers, config) {
if (status == 107) {
promise = flickrService.get(...);
promise.success(function (data, status, headers, config) {
// Big Party
})
.error(function (data, status, headers, config) {
AlertService.RaiseErrorAlert("Flickr temporarily unavailable.Please try again later");
});
}
});
If you continue to get a "Protocol Error", then inform the user that Flickr is temporarily unavailable and to try again later.
如果您继续收到“协议错误”,则通知用户 Flickr 暂时不可用并稍后重试。
回答by Mekap
This might be the answer, but i'm guessing that this is probably not a client issue, so i would suggest you to update your api's server with that line added in the header :
这可能是答案,但我猜这可能不是客户端问题,所以我建议你更新你的 api 的服务器,并在标题中添加该行:
Access-Control-Allow-Origin: https://api.flickr.com/*
This should fix the troubles some of your users are facing.
这应该可以解决您的一些用户面临的问题。

