Steven Venham Steven Venham - 4 months ago 17
HTTP Question

Java http server wont receive more then once

So I got this simple java HTTP server together, (I know about Jetty ext. I need my own.)
I can make requests, receives, and put a response. But only once.
Afterwords, I don't receive anything. Which is odd, iv tried killing the connection after every request, to force a reset but it just does not want anything to do with it.

Chrome Dev Tools:
Chrome Dev Tools

While the console shows:

Trying to bind to localhost on port 8080...OK!

Ready, Waiting for connections...
24.---.---.--- connected to server.
24.---.---.--- requested /index.html ... processed OK.
24.---.---.--- connected to server. (I don't get any data, just times out)


I'm Expecting a request for favicon.ico and get nothing.
Secondly, if I refresh the page, I get another connection that just requests nothing. and Chrome reports:

The 24.---.---.--- page isn’t working
24.---.---.--- didn’t send any data.
ERR_EMPTY_RESPONSE


Heres the source.

Tried:


  • Closing the Socket

  • Flushing output

  • Deleting the object

  • Closing all I/o after 1 request.

  • Refactored to use soTimeout to close connection with a timeout.



No idea.

Answer

Problem was not with HTTP server.

After looking at it with fresh eyes, the problem was located in my Thread-pool. The pool was processing 1 request then shutting itself down, making it appear to be a HTTP issue.

RequestHelper.execute()

Does not behave like you would expect, it adds it to the queue, instead of you having to make a loop to pop Runnable objects from a List stack.