我使用javascript作为客户端,如:
var socket = io.connect('http://localhost:3700', {
'reconnection delay': 2000,
'force new connection': true
});
socket.on('connect', function () {
console.log('connected to port 3700');
});
Java Server代码:
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(3700);
final SocketIOServer server = new SocketIOServer(config);
server.addConnectListener(new ConnectListener() {
public void onConnect(SocketIOClient client) {
System.out.println("onConnected");
}
});
获得以下错误:
无法加载资源:服务器响应状态为400(错误请求) http://localhost:3700/socket.io/?EIO=3&transport=polling&t=LJeUh3G无法加载资源:服务器响应状态为400(错误请求)
http://localhost:3700/socket.io/?EIO=3&transport=polling&t=LJUULaA无法加载资源:net :: ERR_CONNECTION_REFUSED
socket.io.js:1 GET http://localhost:3700/socket.io/?EIO=3&transport=polling&t=LJUUMoQ net :: ERR_CONNECTION_REFUSED