Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not send response to the client ,version:2.3.1 #564

Open
higersister opened this issue Oct 15, 2019 · 10 comments
Open

Could not send response to the client ,version:2.3.1 #564

higersister opened this issue Oct 15, 2019 · 10 comments

Comments

@higersister
Copy link

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)

@macedoraf
Copy link

i've the same problem

@RowlandOti
Copy link

RowlandOti commented Oct 30, 2019

Are you streaming a file or sending the whole of it at once?

  • Is a new connection getting created for new and subsequence requests for the same resource

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.

@sunnyamuren
Copy link

I have the same issue

@sunnyamuren
Copy link

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.(GZIPOutputStream.java:94)
at java.util.zip.GZIPOutputStream.(GZIPOutputStream.java:109)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectEncoding(NanoHTTPD.java:1663)
at fi.iki.elonen.NanoHTTPD$Response.sendBodyWithCorrectTransferAndEncoding(NanoHTTPD.java:1654)
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:784)

@FonzTech
Copy link

FonzTech commented Nov 7, 2019

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!

@mvock
Copy link

mvock commented Jan 11, 2020

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.

@FonzTech
Copy link

FonzTech commented Jan 11, 2020

@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.

@timehaswings
Copy link

I have the same issue

@FonzTech
Copy link

I have the same issue

Try a previous version, if it's not a problem for you.

@pir8radio
Copy link

pir8radio commented Sep 23, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants