带有FormData的Firefox AJAX POST从未完成 [英] Firefox AJAX POST w/ FormData Never Completes

查看:70
本文介绍了带有FormData的Firefox AJAX POST从未完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过AJAX和FormData上传文件,作为输入文件控件的change事件的一部分.$ form变量是对我的表单的jQuery引用(如果那不是很明显).

I am uploading a file as part of the change event of my input file control via AJAX and FormData. The $form variable is a jQuery reference to my form (if that wasn't obvious).

$.ajax(url, {
    contentType: false,
    data: new FormData($form[0]),
    method: "post",
    processData: false
}).fail(function(xhr, status, error) {
    console.log(xhr.responseText);
    console.log(status);
    console.log(error);
})

当我在本地测试时,此功能可在IE,FF和Chrome中使用.将应用程序部署到我们的质量检查环境后,它仅在FF(50.1.0 64位)中停止工作.我可以在网络"标签中看到POST,但是左侧的圆圈保持灰色,好像仍在等待处理.

This works in IE, FF and Chrome when I test locally. Once the application is deployed to our QA environment it stops working ONLY in FF (50.1.0 64bit). I can see the POST in the network tab, but the circle to the left stays grey as if it's still pending.

FF开发者工具屏幕截图

该请求确实失败"并调用我的函数,但没有提供任何有趣的信息(在屏幕快照中也提供了console.log输出).

The request does "fail" and call my function, but there isn't any interesting information provided (console.log output available in screenshot also).

我认为这可能是CORS的问题,但是在about:config中摆弄并安装CORS Everywhere插件并没有改变结果.

I thought perhaps it could be a CORS issue, but fiddling around in about:config and installing the CORS Everywhere plug-in did not yield a change in results.

本地测试和QA测试环境之间的显着区别是QA环境是负载平衡的SSL卸载配置.我们使用的SSL证书是通配符,表示它可用于任何* .company.com网站.本地测试是纯文本.

Notable differences between local testing and QA testing environments are that the QA environment is a load balanced SSL offloading configuration. The SSL certificate we use is a wildcard meaning it works for any site *.company.com. Testing locally is plain text.

我确实尝试了一些

I did try some of the suggestions made here, but to no avail.

我尝试的最后一件事是使用Fiddler来查看FF和应用程序服务器之间发生的情况.将Fiddler设置为解密HTTPS流量后,该过程开始工作(奇怪).当Fiddler捕获但不解密HTTPS流量时,它不起作用(就像Fiddler不在运行一样).这使我相信这可能与证书有关?

The last thing I tried was using Fiddler to see what was happening between FF and the application server. When Fiddler is set to decrypt HTTPS traffic the process starts working (weird). When Fiddler is capturing but NOT decrypting HTTPS traffic it doesn't work (just as if Fiddler wasn't running). This leads me to believe it could be certificate related?

我正在寻找可能的问题的建议/想法.

I'm looking for suggestions/ ideas on what could be the issue.

我已经做了进一步的实验,并确定提交一个空的FormData将会POST到服务器:

I've done further experimenting and determined that submitting an empty FormData will POST to the server:

$.ajax(url, {
    contentType: false,
    data: new FormData(),
    method: "post",
    processData: false
})

带有一些垃圾文本键/值对的FormData也将如此:

As will a FormData with some garbage text key/ value pair:

var d = new FormData();
d.append("key", "value");
$.ajax(url, {
    contentType: false,
    data: d,
    method: "post",
    processData: false
})

当尚未选择任何文件(FormData带有空文件)时,发布也会成功.

POSTing will also succeed when no file has yet been selected (FormData with empty File).

我还确定,通过HTTP而不是HTTPS访问应用程序可以使Firefox重新开始工作(尽管我仍然不明白为什么).失败的组合似乎是HTTPS +文件数据.我还确认了触发错误回调时xhr.status = 0和xhr.readyState = 0.

I have also determined that accessing the application over HTTP instead of HTTPS allows Firefox to start working again (although I still don't understand why). The failing combination seems to be HTTPS + file data. I also confirmed that xhr.status = 0 and xhr.readyState = 0 when the error callback is fired.

使用ProcMon,我可以确定我的请求始终在离开Firefox,并将其发送到我们的负载均衡器(SSL终止),但从未离开负载均衡器(没有匹配的Apache日志条目).相同的配置仍适用于IE和Chrome,因此我不确定Firefox是否以负载均衡设备(Cisco ACE)拒绝请求的方式形成请求.

Using ProcMon I was able to determine that my request is always leaving Firefox and making it to our load balancer (where SSL is terminated), but never leaving the load balancer (no matching Apache log entry). This same configuration still works for IE and Chrome so I'm uncertain if Firefox is forming the requests in such a way that they are being rejected by the load balancing appliance (Cisco ACE).

推荐答案

我们已经确定问题出在我们的SSL终止/负载平衡应用程序的CISCO ACE设备上.正在处理数据包数据并阻止了请求的完成.此处是引用该问题的文章,设置进行调整.

We've determined that the issue is the CISCO ACE appliance we have SSL terminating/ load balancing our application. Something is mangling the packet data and preventing the request from completing. Here is the article that references the issue and the settings to adjust.

这篇关于带有FormData的Firefox AJAX POST从未完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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