java.net.SocketException: sendto failed: EPIPE (Broken pipe)

用Socket 模拟http post 上传数据时遇如下问题

异常信息:

07-31 16:05:49.165: W/System.err(16351): java.net.SocketException: sendto failed: EPIPE (Broken pipe)
07-31 16:05:49.165: W/System.err(16351): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:499)
07-31 16:05:49.165: W/System.err(16351): at libcore.io.IoBridge.sendto(IoBridge.java:468)
07-31 16:05:49.165: W/System.err(16351): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)
07-31 16:05:49.165: W/System.err(16351): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
07-31 16:05:49.165: W/System.err(16351): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
07-31 16:05:49.165: W/System.err(16351): at java.io.BufferedOutputStream.write(BufferedOutputStream.java:131)
07-31 16:05:49.165: W/System.err(16351): at java.io.OutputStream.write(OutputStream.java:82)
07-31 16:05:49.168: W/System.err(16351): Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
07-31 16:05:49.168: W/System.err(16351): at libcore.io.Posix.sendtoBytes(Native Method)
07-31 16:05:49.172: W/System.err(16351): at libcore.io.Posix.sendto(Posix.java:147)
07-31 16:05:49.172: W/System.err(16351): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
07-31 16:05:49.172: W/System.err(16351): at libcore.io.IoBridge.sendto(IoBridge.java:466)

该问题为:客户端看到的是连接建立,但实际连接通道已关闭,客户端未感知,一但再发送数据时就会产生该异常。

后发现请求头写的有问题,不规范导致。

你可能感兴趣的:(java)