NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.96k stars 1.7k forks source link

Refuse connection and timeout #646

Open t104360088 opened 5 months ago

t104360088 commented 5 months ago

Hi, I have an Android application, running nanohttpd on it to provide web pages to the browser under LAN, but I encountered a very strange problem.

Sometimes the browser will show the connection refuse or the connection times out, but at this time I use another PC to request the web page from server and get a normal response. After a while, the PC that was originally unable to connect can get the web page again. Does anyone have any ideas about this problem?

tejmagar commented 4 months ago

I was facing similar problems where connection disconnects and large file upload fails. Try running the server in foregorund service.

Looks like this library is no more maintained so I tried to make my own http server library. https://github.com/tejmagar/tinyweb

t104360088 commented 4 months ago

This problem is very strange, I know there is a fix in the unreleased commit, but even with this, I still encounter the connection timeout problem, and I find that I can't get a response when using ping, and it returns to normal after rebooting, are there any restrictions on Android?

removed remoteHostName from HTTPSession: it can take too long time to figure out via DNS