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



范围错误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的哪个版本?我可能认为,最近对该项目的承诺为您改进了一些东西,并支持HTTP1.1协议(即连接处理的"保持活动"部分)。

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

此外,我将了解NanoHttpd处理"范围"请求的方式,尤其是像堆栈跟踪指示的正在发送的开放式范围。

谢谢!

最新更新