我无法使用gottox中的socket.io-java-client从java连接到我的node.js服务器。我从beenjaminn here开始遵循socket.io v.1.0.6的构建建议。
这是我的连接命令:
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请求一个html页面,该页面下载上面的js,然后在上面的行中建立websocket连接。
我的java客户端连接有什么问题?