范围错误Java NanoHTTPD服务HTTP实时流

我正在尝试使用基于Java的NanoHTTPD HTTP服务器来提供HLS视频流。我也在使用VLC播放.m3u8文件。有趣的是VLC可以播放我的视频,但NanoHTTPD抛出“ java.net.SocketException”。我正在使用NanoHTTPD附带的SimpleWebServer.java

这是我的.m3u8文件

#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


这是我的Eclipse控制台
    服务器启动,按Enter停止。

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.

最佳答案

您正在使用哪个版本的NanoHttpd?我可能是最近对该项目的提交为您提供了改进,并得到了HTTP 1.1协议的支持(即,连接处理的“保持活动”部分)。

我很想知道您是否遇到了最新版本(2.0.3)的NanoHttpd问题。

另外,我将看一下NanoHttpd处理“范围”请求的方式-尤其是开放范围,例如堆栈跟踪指示正在发送。

谢谢!

10-07 23:20