Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Http server and broken pipes
    text
    copied!<p>I'm trying to develop an Android UPnP application that has an embedded http server in it, so it can serve media files from the device over lan.</p> <p>The first implementacion of the web server that I used was based on the ElementalHttpServer example from Apache HttpCore <a href="http://hc.apache.org/httpcomponents-core-ga/index.html" rel="nofollow">http://hc.apache.org/httpcomponents-core-ga/index.html</a>. It had to be changed a little bit because the org.apache.http elements that are already included in the Android library differed from the latest included in the httpCore jar.</p> <p>I tried to substitute the Android ones with the ones from the jar but that couldn't be done - the ones in the Android library have the priority. When I change the library order there was a problem with duplicate classes.</p> <p>Than instead of the jars I included source code and change the packet names to avoid duplicated classes problem.</p> <p>The problem with the broken pipe and connection problems persisted.</p> <p>I've also tried the NHttpServer from HttpCoreNIO since it has different set of classes than the basic httpCore and could be included and used without conflicting with the httpCore in the Android itself.</p> <p>Then I used NanoHTTPD which seems to work the best of all the http servers so fat but is still troubled by the same problem as all the others:</p> <pre><code>java.net.SocketException: The connection was reset at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Method) at org.apache.harmony.luni.platform.OSNetworkSystem.sendStream(OSNetworkSystem.java:498) at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:585) at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59) at com.zappotv.network.http.NanoHTTPD$HTTPSession.sendResponse(NanoHTTPD.java:828) at com.zappotv.network.http.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:478) at java.lang.Thread.run(Thread.java:1096) </code></pre> <p>and</p> <pre><code>java.net.SocketException: Broken pipe at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Method) at org.apache.harmony.luni.platform.OSNetworkSystem.sendStream(OSNetworkSystem.java:498) at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:585) at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59) at com.zappotv.network.http.NanoHTTPD$HTTPSession.sendResponse(NanoHTTPD.java:828) at com.zappotv.network.http.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:478) at java.lang.Thread.run(Thread.java:1096) </code></pre> <p>Recently I have implemented iJetty into the app but the problem still persists. Sometimes the requesting device goes into an endless loop of requests.</p> <p>What could I be doing wrong? May the headers be a problem ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload