HttpPost文件上传数据丢失 [英] HttpPost fileupload data loss

查看:977
本文介绍了HttpPost文件上传数据丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的应用我将文件上传到使用这个基本code我们的服务器(这是比这当然有点多,但是这基本上是吧)

From my app I upload a file to our server using this basic code (it is a bit more than this of course but this is basically it)

HttpParams params = new BasicHttpParams(); 
HttpConnectionParams.setConnectionTimeout(params, 15000); 
HttpConnectionParams.setSoTimeout(params, 5 * 60 * 1000); 
HttpClient client = new DefaultHttpClient(params); 
HttpPost  post = new HttpPost("upload url"); 
HttpEntity requestEntity = (new FileEntity(tmpFile, "multipart/form-data;boundary="+boundary); 
post.setEntity(requestEntity); 
HttpResponse response = (HttpResponse) client.execute(post); 

这是正常工作的大部分时间。

That works fine MOST of the time.

对于一些手机运行Android 2.2+服务器接收到的文件
侧是不完整的。该文件的一小部分被简单地丢失,
而且缺少部分是在该文件的不同位置
每一次。

For some phones running Android 2.2+ the file received on the server side is not complete. Small portions of the file are simply missing, and the parts that are missing are at different locations of the file each time.

我们已经通过将文件从对应用程序进行比较验证了这是什么
被接收在服务器端。在服务器端,我们抓获
使用tcpdump数据包,以确保它不符合我们的网站的一个问题
服务器或Web服务器code。

We have verified this by comparing the file from the app against what is received on the server side. On the server side we captured packets with tcpdump to make sure it wasn't an issue with our web server or web server code.

我们还从手机tcpdump的检查数据。从手机的tcpdump的文件确实来自我们要发送的数据有差异。对于一个情况下,我们做了tcpdump的文件分析缺少从文件中的地址8d68和9000之间的数据。从tcpdump的线与这些地址的数据包(一个包具有数据的部分,直到8d68再下一分组已经数据从9000开始)。

We also checked the data with tcpdump from the phone. The tcpdump file from the phone DOES differ from the data we are trying to send. For one case we did analysis on the tcpdump file is missing data between the address 8d68 and 9000 from the file. The packets from tcpdump line up with those addresses (one packet has a portion of the data up until 8d68 and then the next packet has data starting from 9000).

有关这些手机的问题只发生在某些时候。有时
文件上传工作,整个文件收到完整的在我们这边。

For these phones the problem only happens some of the time. Sometimes file uploads work and the entire file is received intact on our end.

这仅仅是发生了2.2+手机。它发生于多种
的手机,以及各种载体,并为数百个用户。看来基于看到在服务器端的IP地址发生了WiFi和3G网络。

This is happening ONLY for 2.2+ phones. It happens for a wide variety of phones, and a variety of carriers, and for hundreds of users. It appears to happen over both wifi and 3g based on the IP addresses seen on the server side.

这是传闻,但试图让这在近2天,我已经看到它发生的6倍和时代总是对周围当我进入或离开房间接近到一定的WiFi路由器上我的Nexus发生时。在一天剩下的时间,当我在办公室不同的无线路由器或细胞网络问题从未发生过的。我的理论是,该应用程序是忙于发送数据,现在我们从无线网络到手机网络,反之亦然移动,是一个愚蠢的想法或一种可能性?

This is anecdotal but when trying to get this to happen on my Nexus over the past 2 days I have seen it happen 6 times and those times are always right around when I am entering or leaving the room close to a certain wifi router. The rest of the day when I'm in the office on a different wifi router or on a cell network the issue never happens. My theory being that the app is busy sending data and now we move from wifi to cell network or vice versa, is that a dumb idea or a possibility?

我可以把tcpdump的文件和数据文件在哪儿,如果有人关心去看看。

I can put the tcpdump files and data files up somewhere if anyone cares to take a look.

还有什么我应该调查找出这样做的原因?

What else should I be investigating to figure out the reason for this?

推荐答案

我上传二进制数据时面临着一些类似的问题。我想通了,这是与服务器code的一个问题。
有一些过滤器在服务器端,这在读传入的请求,并尝试登录他们。在code试图把输入流在DS的某些字符串类型。其是因为这样,在二进制图像进行扭曲。
只是检查是否有在服务器端的过滤器。希望这有助于

I was facing some similar issue when uploading the binary data. I figured out that it was a problem with the server code. There were some filters at the server side, which were reading the incoming requests and trying to log them. The code was trying to put the incoming stream in some String type of DS. Its was because of this that the binary images were distorted. Just check if there are any filters at the server side. Hope this helps

这篇关于HttpPost文件上传数据丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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