Open higersister opened 5 years ago
i've the same problem
Are you streaming a file or sending the whole of it at once?
You may need to add support for byte download if you are downloading stuff. Also may be great to check how many threads are allowed in the server.
I have the same issue
t E/fi.iki.elonen.NanoHTTPD: Could not send response to the client
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:117)
at java.net.SocketOutputStream.write(SocketOutputStream.java:149)
at fi.iki.elonen.NanoHTTPD$Response$ChunkedOutputStream.write(NanoHTTPD.java:1442)
at fi.iki.elonen.NanoHTTPD$Response$ChunkedOutputStream.write(NanoHTTPD.java:1435)
at java.util.zip.GZIPOutputStream.writeHeader(GZIPOutputStream.java:182)
at java.util.zip.GZIPOutputStream.
This happens to me when loading an audio through JavaFX's WebView.
EDIT: This error does not happen on old version. I tried the 2.1.1 on Maven Repository. It works even with the JavaFX's WebView!
In my case, I got this error after calling com.fasterxml.jackson.databind.ObjectMapper#readTree(session.getInputStream()). Reading the body myself with InputStream.readNBytes(length) where length is the value of the content-length header works.
@mvock I think the problem is due to NanoHttpd that closes the socket too early (or it sends a command causing the other side to close the socket, causing a broken pipe) but then it continues to write to it.
I have the same issue
I have the same issue
Try a previous version, if it's not a problem for you.
so try an old version is the fix? :-) I see this just serving up json API requests on a reasonably busy server. maybe the json response is long? not sure the pattern, I run a production and a test, my test only has 6 or so users hitting it every few seconds, the problem server (production) has 180 users all hitting the api call every second or two. I see zero of these errors on the low traffic test server, but constantly on the production server. if that helps.. are there any timeouts or settings I could look into?
Sep 23, 2023 10:31:36 AM fi.iki.elonen.NanoHTTPD$Response send SEVERE: Could not send response to the client java.net.SocketException: Software caused connection abort: socket write error at java.base/java.net.SocketOutputStream.socketWrite0(Native Method) at java.base/java.net.SocketOutputStream.socketWrite(Unknown Source) at java.base/java.net.SocketOutputStream.write(Unknown Source) at fi.iki.elonen.NanoHTTPD$Response$ChunkedOutputStream.finish(NanoHTTPD.java:1448) at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectTransferAndEncoding(NanoHTTPD.java:1655) at fi.iki.elonen.NanoHTTPD$Response.send(NanoHTTPD.java:1624) at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:957) at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) at java.base/java.lang.Thread.run(Unknown Source)
java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:112) at java.net.SocketOutputStream.write(SocketOutputStream.java:157) at fi.iki.elonen.NanoHTTPD$Response.sendBody(NanoHTTPD.java:1694) at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectEncoding(NanoHTTPD.java:1667) at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectTransferAndEncoding(NanoHTTPD.java:1657) at fi.iki.elonen.NanoHTTPD$Response.send(NanoHTTPD.java:1624) at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:957) at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) at java.lang.Thread.run(Thread.java:761)