Invalid WebSocket frame: invalid payload length 126

14 Apr 2020, 09:44

Sometime I get this error. What is it and how to fix ?

  colyseus:errors RangeError: Invalid WebSocket frame: invalid payload length 126
  colyseus:errors     at Receiver.getInfo (/home/godate/node_modules/ws/lib/receiver.js:216:16)
  colyseus:errors     at Receiver.startLoop (/home/godate/node_modules/ws/lib/receiver.js:130:22)
  colyseus:errors     at Receiver._write (/home/godate/node_modules/ws/lib/receiver.js:77:10)
  colyseus:errors     at doWrite (_stream_writable.js:415:12)
  colyseus:errors     at writeOrBuffer (_stream_writable.js:399:5)
  colyseus:errors     at Receiver.Writable.write (_stream_writable.js:299:11)
  colyseus:errors     at TLSSocket.socketOnData (/home/godate/node_modules/ws/lib/websocket.js:876:35)
  colyseus:errors     at TLSSocket.emit (events.js:197:13)
  colyseus:errors     at addChunk (_stream_readable.js:288:12)
  colyseus:errors     at readableAddChunk (_stream_readable.js:269:11)
  colyseus:errors     at TLSSocket.Readable.push (_stream_readable.js:224:10)
  colyseus:errors     at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:145:17) +0ms```
14 Apr 2020, 09:50

hi @boygiandi, which client are you using?

14 Apr 2020, 11:47

React native, When I got this error I'm testing on iOS simulator. It just happen sometime.

14 Apr 2020, 12:36

I see, is this error crashing the server, or it just prints this error and server continues running?

I've never seen this, but here the author of the ws package explains what this error means: https://github.com/websockets/ws/issues/1662#issuecomment-555526971

14 Apr 2020, 12:37

Yes. It crash server

14 Apr 2020, 12:40

Ah.. I'm sorry. I didn't make server crash. Just make the client disconnected.

15 Apr 2020, 01:04

@endel Is there any way to fix it ?

9 May 2020, 21:53

I confirm the problem in react native (ios sim, 13.3). For me it just disconnects the client randomly, but server runs normally after the error; it just reports error to stdout.

6 Jul 2020, 13:40

I have same problem with JS client. Can be this caused by large state?

8 Sept 2020, 13:59

It seem like not only colyseus server is affected:

https://github.com/parse-community/parse-server/issues/6173
https://github.com/parse-community/parse-server/issues/6413

I created a bug for colyseus to handle this particular error in graceful way and keep clients connected:
https://github.com/colyseus/colyseus/issues/364