Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"RangeError: Invalid WebSocket frame: invalid payload length" error on server #33

Closed
serjek opened this issue May 9, 2020 · 11 comments
Closed

Comments

@serjek
Copy link
Collaborator

serjek commented May 9, 2020

Following error occurs randomly on server side (0.13.0-0.13.5) with latest haxe client (0.13.1):

RangeError: Invalid WebSocket frame: invalid payload length 126
    at Receiver.getInfo (/node_modules/ws/lib/receiver.js:213:16)
    at Receiver.startLoop (/node_modules/ws/lib/receiver.js:127:22)

As suggested on help channel this might be related to server and client incompatibility, this is why I believe haxe client is missing something.

@serjek serjek changed the title RangeError: Invalid WebSocket frame: invalid payload length on server "RangeError: Invalid WebSocket frame: invalid payload length" error on server May 9, 2020
@endel
Copy link
Member

endel commented May 9, 2020

Thanks for reporting @serjek, seems to be related with https://discuss.colyseus.io/topic/351/invalid-websocket-frame-invalid-payload-length-126

Not sure what's the cause of it though

@endel
Copy link
Member

endel commented May 9, 2020

This seems to be happening in native environments somehow (the issue reported on the forum was React Native)

Do you see this error on a specific platform @serjek?

@serjek
Copy link
Collaborator Author

serjek commented May 9, 2020

Indeed, client is react native running in iOS simulator (13.3). Where do I start debugging this?

@endel
Copy link
Member

endel commented May 9, 2020

I'm inspecting the _onMessage (source) on ReactNative / iOS and getting really strange results. room.send() is not working because the first byte received on the server is 146 instead of 13. I'm using the colyseus.js client though.

 [
  146,  13, 164,
  116, 121, 112,
  101
]

Also, the state is not being broadcasted back to the client.

@endel
Copy link
Member

endel commented May 9, 2020

Sorry, this error I've seen is probably because I had a cached version of colyseus.js@0.12 on my environment. I'll try to reproduce the one you mentioned.

@endel
Copy link
Member

endel commented May 9, 2020

I'd appreciate if you can share something that is possible to reproduce, I've been trying to send a lot of messages back and forth and couldn't reproduce the error it myself. 😢

@serjek
Copy link
Collaborator Author

serjek commented May 10, 2020

hey sure, I will try to nail down the problem. To think of it, I believe this more like is an edge case related to hot reload feature in RN: when you reload the application it still retains old socket connections and it might happen that there are some stale messages still passing through old socket which can cause the error.

@serjek
Copy link
Collaborator Author

serjek commented May 10, 2020

Most likely it's related to how colyseus tries to preserve session/client. Got it reproduced after app reload:
first error:
trying to send data to inactive client dyrkfWqF4
after app reload:
Invalid WebSocket frame: invalid payload length 126

@serjek
Copy link
Collaborator Author

serjek commented May 17, 2020

Apparently it's not an edge case as my server error log is full of these errors after I opened public beta. Still investigating what might be a problem here.

@serjek
Copy link
Collaborator Author

serjek commented May 17, 2020

here are bytes that are coming from client [138, 254]. @endel any ideas what this might be? Problem is that server immediately closes connection after that so, may be server can be configured so that it don't drop connection if some rubbish sometimes is coming from client?

@serjek
Copy link
Collaborator Author

serjek commented Sep 24, 2020

seem to be react native issue: facebook/react-native#30020

@serjek serjek closed this as completed Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants