1

In my app, I create a local NanoHttpd server giving it the path of video file to serve. then, start another app to play from the stream.Now, since I don't want that server to run forever.

  • Is there any way I can know that other app has stopped receiving data(or is closed) or,
  • can I put any timeout in NanoHttpd so that it closes itself.

I am new to nanohttpd, http. Any suggestion that gain the final result is welcome.

Prince
  • 99
  • 1
  • 11

2 Answers2

4

set the SOCKET_READ_TIMEOUT in NanoHttpd for your own TimeOut. By default it is 5000.

Manas Pratim Chamuah
  • 1,527
  • 2
  • 15
  • 33
  • Will this actually stop the server after the set timeout? I have a server that has been running for 2 hours now(intentionally though) and I'm still able to make requests to it. I didn't pass any timeout. If the default is 5000, shouldn't the server have closed by now? – Stylishcoder Jan 21 '19 at 12:30
0

Maybe I'm a bit late, but you can also set SOCKET_READ_TIMEOUT when starting your NanoHTTPD server:

NanoHTTPD server = new NanoHTTPD(yourPort);
server.start(readTimeout);
Iria Somobu
  • 79
  • 1
  • 7