Error while reading inputstream : Software caused connection abort' in java server Error while reading inputstream : Software caused connection abort' in java server android android

Error while reading inputstream : Software caused connection abort' in java server


I can't reproduce your issue locally, and something tells me that your trigger conditions are pretty specific, but here are a few things to try to help you diagnose and fix your problem.

  1. Your code: If it's your code, then existing web server code should work. Try the code in the code from this nice minimal Medium article on how to create your own Java web server.
  2. The Firewall: If it's the firewall, contact your network admin person/team etc. If you don't know who it is, just talk to as high profile a person in your company that you feel comfortable asking and they should be able to direct you to the right person.
  3. Socket SO_KEEPALIVE Option: I found an interesting SuperUser question on the subject, and read that this issue may be caused by the fact that you don't have the SO_KEEPALIVE flag set on your socket. The answer talks about PuTTY, but I thought it it might be worthwhile to try on your Java socket. It's certainly a low hanging fruit to try. As such, try adding via calling connectionSocket.setKeepAlive(true); just after the Socket connectionSocket = serverSocket.accept(); line.


I tried to run your code in my pc (not in Android) and it work good with a simply call from browser to `localhost:8080'.

I think you can do the same inside your device just to know if it's a client problem.

I edited this two lines to avoid long waiting:

byte[] contentBytes = new byte[10];    for (int i = 0; i < 10; i++) {