2015-10-17 108 views
1

嗨所以我试图从Gottox运行socket.io-java-client,并简单地通过在eclips中打开项目(导入)并运行BasicExample.java我是收到此错误运行gottox/socket.io-java客户端错误

错误而握手 服务器返回的HTTP响应代码:400网址:http://localhost:3000/socket.io/1/

我尝试了许多解决办法,但无法运行它,还我运行上的NodeJS服务器端口3000.

var app = require('express')(); 
var http = require('http').Server(app); 
var io = require('socket.io')(http); 

app.get('/', function(req, res){ 
res.sendfile('index.html'); 
}); 

io.on('connection', function(socket){ 
console.log('a user connected'); 

socket.on('message', function(msg){ 
io.emit('message', msg); 
console.log('1111111111111111111'); 
}); 
}); 

http.listen(3000, function(){ 
console.log('listening on *:3000'); 
}); 

回答

2

您的节点服务器上安装socket.io的旧版本(< 1.0):

npm uninstall socket.io 
npm install -g [email protected] 

我用Gottox库在我的项目,它似乎并没有与socket.io 1.0版工作+

A more recent Java socket.io library that works with version 1.0+

+0

感谢它的工作!!,但有没有机会在新版本上工作? – user614946

+0

我认为图书馆将不得不更新。在github上它看起来从2013年起还没有更新过。但我并不是100%确定。 – samgak