android socket通信报错“recvfrom failed:npm econnresetT (Connection reset by peer)”

ClientAbortException:&&java.net.SocketException:&Connection&reset&by&peer:&socket&write&error
昨天发现了这个问题,没查到原因,今天又调试了一下,发现是由于使用Ajax,请求的内容返回给客户端后,有些内容在服务器端找不到,找不到就会报404,
由于我在web.xml中设置了转向到error404页面,所以就出现了下面的错误.
警告: Exception Processing ErrorPage[errorCode=404,
location=/jsp/error404.jsp]
ClientAbortException:&
java.net.SocketException: Connection reset by
peer: socket write error
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:331)
org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:295)
org.apache.catalina.connector.Response.flushBuffer(Response.java:545)
org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:287)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
java.lang.Thread.run(Thread.java:595)
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)_百度知道
Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
hiphotos://a://a,服务器接收到数据之后再发送回客户端,客户端可以发送数据到服务器android开发.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="http。<a href="/zhidao/wh%3D450%2C600/sign=49d092e85b82b2b7a7ca31c/f3d3572c11dfa9ec62875cfb60d0fb5.jpg" esrc="http://a.com/zhidao/pic/item/f3d3572c11dfa9ec62875cfb60d0fb5.hiphotos.hiphotos./zhidao/wh%3D600%2C800/sign=2123e0b59c729d0475ba/f3d3572c11dfa9ec62875cfb60d0fb5,但客户端收不到服务器返回的数据
我有更好的答案
3:并发连接的服务器的数目超过了其承载能力:客户关掉了浏览器和服务器仍然是发送数据到客户端,其中一些将被连接到服务器已关闭
其他类似问题
为您推荐:
recvfrom的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁当前访客身份:游客 [
当前位置:
在使用xutil框架下载的时候暂停以后继续下载会抛出这个异常:
04-01 11:46:08.647: E/onFailure(3351): java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
共有0个答案
有什么技术问题吗?Stack Overflow is a question and answer site for professional and enthusiast programmers. It&#39;s 100% free, no registration required.
I have searched a lot for this exception, which rarelly occur, but I didn't find any relevant answer which can solve my problem,
I am using HttpURLConnection to get response as a xml from a url, it works fine but sometimes i get this exception:
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer),
I have used following code and url1 is my url which gives a xml.
url=new URL(url1);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String result, line = reader.readLine();
while((line=reader.readLine())!=null)
System.out.println("Result: "+result);
Try put urlConnection.setRequestProperty("connection", "close"); before connecting. This will disable keep-alive property which is on by default
open your browser you are using and try copying the urland paste it into your browser of your MOBILE DEVICE , if you still get the same error or may be connection refused that means your MOBILE and YOUR PC on which server runs are not on the same plan.
4,96412460
I had a similar problem when trying to talk with my server. I'm still not sure what happened, but I found
in my search to resolve the issue:
ok, the answer was that it's the server's fault - it had to close the
connection after each request . it might be that android keeps a pool
of connections and use the old one or something like that . anyway ,
now it works.
After reading this post, I killed the apache instance running on my server, let the phone see that the connection was refused, and restarted apache. After that, the issue disappeared. Hope this helps!
1,33811330
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled当前访客身份:游客 [
当前位置:
这段时间做项目,其中要用Socket向后台提交数据,然后接收响应信息,代码在Android&AVD模拟器可以运行,但是真机(通过百度WIFI共享PC机网络连接)运行总是报SocketException,百思不得其解,请各位不吝赐教。
Socket连接部分代码如下(在一个线程类SocketTask中):
public void run( )
Socket socket = new Socket( );
BufferedOutputStream os =
BufferedInputStream ins =
socket.connect( new InetSocketAddress( this.mHostAddress, this.mPort ) );
if ( socket.isClosed( ) || !socket.isConnected( ) )
this.notifyNetworkFailed( SocketStatus.NOT_CONNECTED, this.getRequestURI( ) );
// Send data.
if ( socket.isClosed( ) || socket.isOutputShutdown( ) )
this.notifyNetworkFailed( SocketStatus.OUTPUT_SHUTDOWN, this.getRequestURI( ) );
os = new BufferedOutputStream( socket.getOutputStream( ), this.mData.length );
os.write( this.mData );
os.flush( );
// Read response.
if ( socket.isClosed( ) || socket.isInputShutdown( ) )
this.notifyNetworkFailed( SocketStatus.INPUT_SHUTDOWN, this.getRequestURI( ) );
ins = new BufferedInputStream( socket.getInputStream( ) );
final int totalLength = ins.available( );
final byte[ ] readBuffer = new byte[ READ_BUFFER_SIZE ];
final ByteArrayBuffer buffer = new ByteArrayBuffer( totalLength );
int readBytes = 0;
while ( ( readBytes = ins.read( readBuffer ) ) != -1 )
buffer.append( readBuffer, 0, readBytes );
this.notifyNetworkSucceed( buffer.toByteArray( ) );
catch ( UnknownHostException e )
e.printStackTrace( );
this.notifyNetworkException( e );
catch ( IOException e )
e.printStackTrace( );
this.notifyNetworkException( e );
if ( os != null )
os.close( );
catch ( IOException e )
e.printStackTrace( );
if ( ins != null )
ins.close( );
catch ( IOException e )
e.printStackTrace( );
socket.close( );
catch ( IOException e )
e.printStackTrace( );
} 异常位于:
while ( ( readBytes = ins.read( readBuffer ) ) != -1 ) 异常信息:
07-31&11:08:55.994:&W/System.err(28574):&java.net.SocketException:&recvfrom&failed:&ECONNRESET&(Connection&reset&by&peer)
07-31&11:08:55.999:&W/System.err(28574):& at&libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552)
07-31&11:08:55.999:&W/System.err(28574):& at&libcore.io.IoBridge.recvfrom(IoBridge.java:516)
07-31&11:08:55.999:&W/System.err(28574):& at&java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
07-31&11:08:56.004:&W/System.err(28574):& at&java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
07-31&11:08:56.004:&W/System.err(28574):& at&java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
07-31&11:08:56.004:&W/System.err(28574):& at&java.io.InputStream.read(InputStream.java:163)
07-31&11:08:56.004:&W/System.err(28574):& at&java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
07-31&11:08:56.009:&W/System.err(28574):& at&java.io.BufferedInputStream.read(BufferedInputStream.java:309)
07-31&11:08:56.009:&W/System.err(28574):& at&java.io.InputStream.read(InputStream.java:163)
07-31&11:08:56.009:&W/System.err(28574):& at&com.******.android.network.SocketTask.run(SocketTask.java:127)
07-31&11:08:56.009:&W/System.err(28574):& at&java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
07-31&11:08:56.009:&W/System.err(28574):& at&java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-31&11:08:56.009:&W/System.err(28574):& at&java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-31&11:08:56.014:&W/System.err(28574):& at&java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-31&11:08:56.014:&W/System.err(28574):& at&java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-31&11:08:56.014:&W/System.err(28574):& at&java.lang.Thread.run(Thread.java:856)
07-31&11:08:56.014:&W/System.err(28574):&Caused&by:&libcore.io.ErrnoException:&recvfrom&failed:&ECONNRESET&(Connection&reset&by&peer)
07-31&11:08:56.019:&W/System.err(28574):& at&libcore.io.Posix.recvfromBytes(Native&Method)
07-31&11:08:56.019:&W/System.err(28574):& at&libcore.io.Posix.recvfrom(Posix.java:131)
07-31&11:08:56.019:&W/System.err(28574):& at&libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
07-31&11:08:56.024:&W/System.err(28574):& at&libcore.io.IoBridge.recvfrom(IoBridge.java:513)
07-31&11:08:56.024:&W/System.err(28574):& ...&14&more
共有1个答案
<span class="a_vote_num" id="a_vote_num_
可以先在另外一台PC上通过wifi连接你的PC,使用sokit等socket调试辅助工具来判断是网络连接问题还是你代码运行环境的问题
有什么技术问题吗?
类似的话题}

我要回帖

更多关于 nodejs econnreset 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信