gpt4 book ai didi

java - 运行 Gottox/socket.io-java-client 时出错

转载 作者:行者123 更新时间:2023-11-30 03:13:23 25 4
gpt4 key购买 nike

嗨,所以我尝试从 Gottox 运行 socket.io-java-client,只需在 eclips(import) 中打开项目并运行 BasicExample.java 就可以简单地运行我收到此错误

Error while handshaking Server returned HTTP response code: 400 for URL: http://localhost:3000/socket.io/1/

我尝试了很多解决方案,但无法运行它,而且我正在端口 3000 上运行 Nodejs 服务器。

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');
});

最佳答案

在 Node 服务器上安装旧版本(<1.0)的 socket.io:

npm uninstall socket.io
npm install -g socket.io@0.9.17

我在项目中使用了 Gottox 库,但它似乎不适用于 socket.io 版本 1.0+

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

关于java - 运行 Gottox/socket.io-java-client 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33186671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com