Closed lukaszkurowskilbn closed 1 year ago
I solved the problem by adding in a soket server: "allowEIO3: true,".
@lukaszkurowskilbn thanks for the update :+1:
I think you are using an outdated version, please check https://socketio.github.io/socket.io-client-java/installation.html
Reference for the allowEIO3
option: https://socket.io/docs/v4/server-options/#alloweio3
Hi, I have rewritten the code from the web client to kotlin and it won't connect to the socker.io server can I ask you for help
Client: `import com.github.nkzawa.emitter.Emitter import com.github.nkzawa.socketio.client.IO import com.github.nkzawa.socketio.client.Socket //import io.socket.client.IO //import io.socket.client.Socket //import io.socket.emitter.Emitter //import java.net.Socket
import java.net.URISyntaxException
class SocketIoClient {
// val message = args[0]?.toString() ?: "" // println("Received message: $message") })
} val serverAddress = "http://192.168.11.2:3000" val socketIoClient = SocketIoClient(serverAddress) socketIoClient.sendMessage("Hello, server!") ` Serwer:
` process.env.DEBUG = ''; require('./server'); const express = require('express'); const app = express(); const http = require('http').createServer(app); const uuidG = require('uuidv4'); const io = require("socket.io")(http, { cors: { origin: "", methods: ["GET", "POST"] } });
app.use(express.json());
io.on('connection', socket => { socket.on('message', message => { console.log(message); }); socket.on('joinRoom', room => { socket.join(room.room); console.log(
User joined room: ${room.room}
);app.post('/sendMessage', (req, res) => { const room = req.body.room; if (!io.sockets.adapter.rooms.get(room)) { return res.status(400).send({ error: 'Room does not exist' }); } const uuid = uuidG.uuid(); io.to(room).emit('request', {'message': req.body.message, 'numbers': req.body.numbers, "responseUuid":uuid});
}); }); });
http.listen(3000, () => { console.log('Listening on *:3000'); }); ` Log:
engine:socket received packet pong +3ms engine:socket got pong +1ms engine intercepting request for path "/socket.io/" +5s engine handling "GET" http request "/socket.io/?EIO=3&transport=polling" +1ms engine applying middleware n°1 +0ms engine unsupported protocol version +1ms engine intercepting request for path "/socket.io/" +5s engine handling "GET" http request "/socket.io/?EIO=3&transport=polling" +0ms engine applying middleware n°1 +1ms engine unsupported protocol version +1ms engine intercepting request for path "/socket.io/" +5s engine handling "GET" http request "/socket.io/?EIO=3&transport=polling" +1ms engine applying middleware n°1 +0ms engine unsupported protocol version +1ms engine intercepting request for path "/socket.io/" +5s engine handling "GET" http request "/socket.io/?EIO=3&transport=polling" +1ms engine applying middleware n°1 +0ms engine unsupported protocol version +1ms