2013-06-22 35 views
1

範圍錯誤的Java NanoHTTPD服務HTTP實時流範圍錯誤的Java NanoHTTPD服務HTTP實時流

我嘗試使用基於Java的NanoHTTPD HTTP服務器服務HLS視頻流。我也使用VLC播放.m3u8文件。有趣的是VLC能夠播放我的視頻,但NanoHTTPD正在拋出「java.net.SocketException」。我使用SimpleWebServer.java附帶NanoHTTPD

這裏是我的.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的 控制檯進行服務器啓動時,按回車鍵停止。

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. 

回答

1

您使用的是哪個版本的NanoHttpd?我可能認爲最近對項目的提交改善了你的工作,並且支持HTTP 1.1協議(也就是連接處理的「保持活動」部分)。

我很想知道是否遇到NanoHttpd最新版本(2.0.3)的問題。另外,我將看看NanoHttpd處理「範圍」請求的方式 - 尤其是像你的堆棧跟蹤指示正在發送的開放式範圍。

謝謝!