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

Refuse connection and timeout #646

Open
t104360088 opened this issue Jun 21, 2024 · 3 comments
Open

Refuse connection and timeout #646

t104360088 opened this issue Jun 21, 2024 · 3 comments

Comments

@t104360088
Copy link

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
Copy link

tejmagar commented Jul 6, 2024

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
Copy link
Author

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

@yuedefeng
Copy link

yuedefeng commented Dec 10, 2024

@t104360088 you need to add network permission at 【AndroidManifest.xml】, as follow :

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

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

3 participants