title: Range error Java NanoHTTPD serving HTTP Live Streaming
body: <p>Range error Java NanoHTTPD serving HTTP Live Streaming </p>
  
  <p>I am trying to serve HLS Video stream using Java based NanoHTTPD HTTP server. I am also using VLC to play the .m3u8 file. Funny thing is VLC is able to play my video but NanoHTTPD is throwing "java.net.SocketException". I am using SimpleWebServer.java that ships with NanoHTTPD </p>
  
  <p>Here is my .m3u8 file</p>
  
  <pre><code>#EXTM3U
  #EXT-X-TARGETDURATION:10
  #EXTINF:10,
  sample_320k-1.ts
  #EXTINF:10,
  sample_320k-2.ts
  #EXTINF:10,
  sample_320k-3.ts
  #EXTINF:10,
  sample_320k-4.ts
  #EXTINF:11,
  sample_320k-5.ts
  #EXTINF:11,
  sample_320k-6.ts
  #EXTINF:11,
  sample_320k-7.ts
  #EXTINF:11,
  sample_320k-8.ts
  #EXTINF:10,
  sample_320k-9.ts
  #EXTINF:11,
  sample_320k-10.ts
  #EXTINF:11,
  sample_320k-11.ts
  #EXTINF:10,
  sample_320k-12.ts
  #EXTINF:10,
  sample_320k-13.ts
  #EXTINF:10,
  sample_320k-14.ts
  #EXTINF:10,
  sample_320k-15.ts
  #EXTINF:11,
  sample_320k-16.ts
  #EXTINF:9,
  sample_320k-17.ts
  #EXT-X-ENDLIST
  </code></pre>
  
  <p>Here is my console out from Eclipse
      Server started, Hit Enter to stop.</p>
  
  <pre><code>GET '/' 
    HDR: 'connection' = 'keep-alive'
    HDR: 'accept-language' = 'en-US,en;q=0.8'
    HDR: 'host' = '127.0.0.1:8080'
    HDR: 'accept' = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
    HDR: 'user-agent' = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31'
    HDR: 'accept-encoding' = 'gzip,deflate,sdch'
    HDR: 'accept-charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
  GET '/favicon.ico' 
    HDR: 'connection' = 'keep-alive'
    HDR: 'accept-language' = 'en-US,en;q=0.8'
    HDR: 'host' = '127.0.0.1:8080'
    HDR: 'accept' = '*/*'
    HDR: 'user-agent' = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31'
    HDR: 'accept-encoding' = 'gzip,deflate,sdch'
    HDR: 'accept-charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
  GET '/Http_Live_Streaming/vodhls/stream-local.m3u8' 
    HDR: 'connection' = 'close'
    HDR: 'host' = 'localhost:8080'
    HDR: 'range' = 'bytes=0-'
    HDR: 'icy-metadata' = '1'
    HDR: 'user-agent' = 'VLC/2.0.7 LibVLC/2.0.7'
  GET '/Http_Live_Streaming/vodhls/sample_320k-1.ts' 
    HDR: 'connection' = 'close'
    HDR: 'host' = 'localhost:8080'
    HDR: 'range' = 'bytes=0-'
    HDR: 'icy-metadata' = '1'
    HDR: 'user-agent' = 'VLC/2.0.7 LibVLC/2.0.7'
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  GET '/Http_Live_Streaming/vodhls/sample_320k-2.ts' 
    HDR: 'connection' = 'close'
    HDR: 'host' = 'localhost:8080'
    HDR: 'range' = 'bytes=0-'
    HDR: 'icy-metadata' = '1'
    HDR: 'user-agent' = 'VLC/2.0.7 LibVLC/2.0.7'
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  GET '/Http_Live_Streaming/vodhls/sample_320k-3.ts' 
    HDR: 'connection' = 'close'
    HDR: 'host' = 'localhost:8080'
    HDR: 'range' = 'bytes=0-'
    HDR: 'icy-metadata' = '1'
    HDR: 'user-agent' = 'VLC/2.0.7 LibVLC/2.0.7'
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  GET '/Http_Live_Streaming/vodhls/sample_320k-4.ts' 
    HDR: 'connection' = 'close'
    HDR: 'host' = 'localhost:8080'
    HDR: 'range' = 'bytes=0-'
    HDR: 'icy-metadata' = '1'
    HDR: 'user-agent' = 'VLC/2.0.7 LibVLC/2.0.7'
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  java.net.SocketException
      at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:662)
      at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:124)
      at java.lang.Thread.run(Thread.java:722)
  
  Server stopped.
  </code></pre>