Android网络请求报错:java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
来源:互联网 发布:双十一淘宝文案怎么写 编辑:程序博客网 时间:2024/05/21 11:00
在做文件下载时请求报错:java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
在网上找了半天 有人总结了三个原因:
1、服务器中断;
2、网络连接非常慢的时候
3、下载大文件时,频繁请求服务器,请求的端口一直被占用
解决此问题的办法网上有说Range头设置不对的但是我的问题依然无法解决,有的说google给了解决方案:
private static void disableConnectionReuseIfNecessary() {<span style="white-space:pre"></span>// Work around pre-Froyo bugs in HTTP connection reuse.<span style="white-space:pre"></span>if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.FROYO) {<span style="white-space:pre"></span>System.setProperty("http.keepAlive", "false");<span style="white-space:pre"></span>}}
但是我的问题依然没解决,
最后我查看了一下我的代码发现我用的是get请求 而我这里应该用post请求 丫的 奇怪的是 我用get请求用wifi下载文件是成功的,用手机流量请求联通4G和电信4G也是成功的 只有用移动的4G时会报这个错,搞不懂~~~
0 0
- Android网络请求报错:java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)我的解决办法
- 迷糊的IOException:Java.NET.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- 使用Mob短信验证出现 java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)异常
- *SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- 解决 java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer) 异常
- 解决:java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer)
- libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
- android java.net.SocketException: Connection reset by peer
- socket failed:ECONNRESET(Connection reset by peer)
- Android客户端HTTP请求异常sendto failed: ECONNRESET (Connection reset by peer)解决方案
- java.net.SocketException: recvfrom failed: ECONNRESET
- retrofit sendto failed: ECONNRESET (Connection reset by peer)【android客户端Post请求参数长度限制(参数过大)】解决办法
- java.net.SocketException: Connection reset by peer: socket write error
- java.net.SocketException: Connection reset by peer: socket write error
- 异常:ClientAbortException: java.net.SocketException: Connection reset by peer: socket
- qt-4.7下载地址
- php版本从开始到现在
- wireshark抓包工具查看协议端口号
- java实现基于PKCS7Padding填充方式的AES加解密
- JAVA中的常量
- Android网络请求报错:java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- Fresco介绍:Android的一个新图片库
- 视图控制器管理
- MFC快速入门-hello world
- 自定义ButtonButton
- python 爬虫笔记--简单静态
- 第11周项目4-教师兼干部
- python 系统学习笔记(十二) -- ---os os.path os.walk
- 多级下拉列表选择处理