socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Uncaught Error: unknown packet type NaN

Open startpimp opened this issue 3 years ago • 2 comments

image I'm currently getting this error on [email protected].

I don't know why I am getting this problem, but here is the code I use. There's nothing more from the client-side code, and this is where I'm getting the error :

const WS = io();

function heartbeat() {
  clearTimeout(this.pingTimeout);
  this.pingTimeout = setTimeout(() => {
    this.terminate();
  }, 10000 + 1000);
}


WS.on("open", heartbeat);
WS.on("ping", () => {
	heartbeat();
	WS.emit("pong")
});
WS.on("close", () => {
	clearTimeout(this.pingTimeout);
});

Expected behavior Just a ping control on each client to prevent a bad navigator clising or something else, to disconnect the user in the database.

Platform:

  • OS: Windows 10

startpimp avatar Jul 06 '22 06:07 startpimp

I'm not seeing it in Ubuntu x64 (server and client) with Node 14 and Chrome 103, but someone on my team has seen it with the same repo (on Windows server and client).

Out of curiosity what Node and Chrome versions are you running @startpimp? And are you connecting directly to Node from the client or using HAProxy, nginx, etc. in between?

dhenson02 avatar Jul 14 '22 17:07 dhenson02

I'm using node v16.14.2 and I'm currently running my client on Opera GX, but I can't find its version ; I don't know where it is.

By the way, I'm not using a proxy or something between my server and my client. They are both running on the same machine, in localhost

startpimp avatar Jul 15 '22 14:07 startpimp

This should be fixed by https://github.com/socketio/socket.io-client/commit/c5970231699aa47b00c4a617af4239d0fa90fa53, included in [email protected].

Thanks for the report :+1:

darrachequesne avatar Oct 14 '22 08:10 darrachequesne