Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Node js socket.io-client 4.0.1 Error: server error #7

Open
Jonathan-Gardner opened this issue Apr 14, 2021 · 2 comments
Open

Node js socket.io-client 4.0.1 Error: server error #7

Jonathan-Gardner opened this issue Apr 14, 2021 · 2 comments

Comments

@Jonathan-Gardner
Copy link

Jonathan-Gardner commented Apr 14, 2021

I'm running a SocketIOSharp server trying to connect with a Node js socket.io-client 4.0.1
I'm using the example server and trying to connect with the following client:

const io = require("socket.io-client");

const socket = io.connect("http://127.0.0.1:9001/", { reconnect: true, rejectUnauthorized: false});
socket.on("connect_error", (err) => {
  console.log(err);
});

socket.on("connect", () => {
  console.log(socket.id); // "G5p5..."
});

The server says "Connected" repeatedly as the client tries to connect.
The client however throws this error:

Error: server error
    at Socket.onPacket (C:\...\test-client\node_modules\engine.io-client\lib\socket.js:401:23)
    at XHR.<anonymous> (C:\...\test-client\node_modules\engine.io-client\lib\socket.js:216:14)
    at XHR.Emitter.emit (C:\...\test-client\node_modules\component-emitter\index.js:145:20)
    at XHR.onPacket (C:\...\test-client\node_modules\engine.io-client\lib\transport.js:105:10)
    at callback (C:\...\test-client\node_modules\engine.io-client\lib\transports\polling.js:101:12)
    at Array.forEach (<anonymous>)
    at XHR.onData (C:\...\test-client\node_modules\engine.io-client\lib\transports\polling.js:105:56)
    at Request.<anonymous> (C:\...\test-client\node_modules\engine.io-client\lib\transports\polling-xhr.js:94:12)
    at Request.Emitter.emit (C:\...\test-client\node_modules\component-emitter\index.js:145:20)
    at Request.onData (C:\...\test-client\node_modules\engine.io-client\lib\transports\polling-xhr.js:236:10) { code: 'parser error' }

Edit 1:
if I set the client to use websockets for the transport by default I receive the following error instead:

Error: It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)
    at Socket.onpacket (C:\...\test-client\node_modules\socket.io-client\build\socket.js:210:56)
    at Manager.Emitter.emit (C:\...\test-client\node_modules\component-emitter\index.js:145:20)
    at Manager.emitReserved (C:\...\test-client\node_modules\socket.io-client\build\typed-events.js:59:15)
    at Manager.ondecoded (C:\...\test-client\node_modules\socket.io-client\build\manager.js:207:14)
    at Decoder.Emitter.emit (C:\...\test-client\node_modules\component-emitter\index.js:145:20)
    at Decoder.add (C:\...\test-client\node_modules\socket.io-parser\dist\index.js:117:23)
    at Manager.ondata (C:\...\test-client\node_modules\socket.io-client\build\manager.js:199:22)
    at Socket.Emitter.emit (C:\...\test-client\node_modules\component-emitter\index.js:145:20)
    at Socket.onPacket (C:\...\test-client\node_modules\engine.io-client\lib\socket.js:407:16)
    at WS.<anonymous> (C:\...\test-client\node_modules\engine.io-client\lib\socket.js:216:14)

Seems like the packet is missing the data content when using websockets only
{ type: 0, nsp: '/' }

Any help would be appreciated!

@npatroni
Copy link

i've the same problem, @DustedHam did you find the solution?

@Jonathan-Gardner
Copy link
Author

Jonathan-Gardner commented Oct 27, 2021

Unfortunatly I did not find a solution.
I was using this for a WebRTC signalling service so I didn't need many messages.
I ended up using WebSocketSharp and rolling my own messaging system.

I think a fix may be possible, but I didn't have time to get super farmilier with the inner workings of this library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants