我正在使用NanoHttpd为我的Android应用程序中的视频提供服务,但我收到以下错误请帮助我。
fi.iki.elonen.NanoHTTPD: Could not send response to the client
java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer)
at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:546)
at libcore.io.IoBridge.sendto(IoBridge.java:515)
at java.net.PlainSocketImpl.write(PlainSocketImpl.java:504)
at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:266)
at fi.iki.elonen.NanoHTTPD$Response$ChunkedOutputStream.write(NanoHTTPD.java:1369)
at fi.iki.elonen.NanoHTTPD$Response.sendBody(NanoHTTPD.java:1620)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectEncoding(NanoHTTPD.java:1593)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectTransferAndEncoding(NanoHTTPD.java:1580)
at fi.iki.elonen.NanoHTTPD$Response.send(NanoHTTPD.java:1550)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:937)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.ErrnoException: sendto failed: ECONNRESET (Connection reset by peer)
at libcore.io.Posix.sendtoBytes(Native Method)
at libcore.io.Posix.sendto(Posix.java:206)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:278)
at libcore.io.IoBridge.sendto(IoBridge.java:513)
at java.net.PlainSocketImpl.write(PlainSocketImpl.java:504)
at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:266)at fi.iki.elonen.NanoHTTPD$Response$ChunkedOutputStream.write(NanoHTTPD.java:1369)
at fi.iki.elonen.NanoHTTPD$Response.sendBody(NanoHTTPD.java:1620)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectEncoding(NanoHTTPD.java:1593)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectTransferAndEncoding(NanoHTTPD.java:1580)
at fi.iki.elonen.NanoHTTPD$Response.send(NanoHTTPD.java:1550)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:937)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:818)
一些建议说要添加以下代码来解决问题,我也添加了但没有结果 if(android.os.Build.VERSION.SDK_INT> 9){StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()。permitAll()。build(); StrictMode.setThreadPolicy(政策); } 请帮我。 谢谢