2015-07-03 154 views
0

我無法使用來自gottox的socket.io-java-client從java連接到我的node.js服務器。我遵循了來自beenjaminn here的socket.io v 1.0.6的構建建議。socket.io和java - 連接失敗

這裏是我的連接命令:

socket.connect("http://192.168.1.7:8000/", this); 

這裏是所產生的誤差:

an Error occured 
io.socket.SocketIOException: Error while handshaking 
    at io.socket.IOConnection.handshake(IOConnection.java:323) 
    at io.socket.IOConnection.access$7(IOConnection.java:293) 
    at io.socket.IOConnection$ConnectThread.run(IOConnection.java:200) 
Caused by: java.io.IOException: Server returned HTTP response code: 400 for  
URL: http://192.168.1.7:8000/socket.io/1/player 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1839) 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440) 
    at io.socket.IOConnection.handshake(IOConnection.java:314) 
    ... 2 more 
Jul 03, 2015 11:08:38 AM io.socket.IOConnection cleanup 
INFO: Cleanup 

從使用socket.io NPM模塊的JavaScript我可以連接的罰款。

var socket = io("http://" + location.host + "/player", {reconnection: false}); 

需要注意的是JavaScript客戶端首先從192.168.1.7:8000其下載JS以上,然後讓在上面就行了WebSocket連接請求的HTML頁面。

我的java客戶端連接有什麼問題?

+0

返回的HTTP響應代碼:400,聽起來像壞請求http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html – Proxytype

回答