-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Websocket Wrong Control Frame [iOS] #30020
Comments
This looks like the PONG frame sent by react-native is causing this problem.
In this scenario described by @vitalyrotari, the server-side is crashing due to what seems to be an invalid control frame being sent by the client. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Same issue. |
any updates for this? |
This bug has been around since 2015... how has it never become a priority? |
Can confirm this issue still. Any workarounds? Is there a way to configure NodeJS server to catch this and gracefully handle it instead of crashing? |
@knro Depends on your server. If you're using import WebSocket from 'ws';
...
const server = new WebSocket.Server({ ... });
server.on('connection', (socket, req) => {
...
// Make sure to add this error handler here so your server doesn't crash
// If you want, filter out the 126 error
socket.on('error', (err) => console.error('socket error', err));
...
}) I continue to log this error in our production server just for fun and to get a sense of the scale of the problem. It happens constantly all day long. If we couldn't prevent the crash our app would be unusable. |
I just disabled built-in ping-pong and made my custom implementation. |
I had not experienced this issue until recently after implementing graphql-ws |
you mean you replaced default RN websocket lib with this one or what? |
@forbesgillikin we're using graphql-ws and we're having a similar problem, but it should be resolved in version 5.5.5 of graphql-ws: https://github.com/enisdenjo/graphql-ws/releases/tag/v5.5.5 For those using graphql-ws, the problem should not be related to ping/pong control frames, since the standard ping implementation of graphql-ws does not send any payload, and the react-native pong implementation just echoes it back (see here). The fix on the react-native side should be to do a check similar to this one when sending a frame in _sendFrameWithOpcode, and either truncate the message or report an error. The ws node library, for example, chooses to throw an error in this cases (see here). |
Upgrading graphql-ws to 5.5.5 did not solve the problem for us: we're still seeing several warnings, and the actual bug seems to be with pong frames, not close frames. What happens is:
This does not happen consistently, and may be a race condition on the RN implementation of websockets. Haven't yet had the time to look into it. |
This bug seems to have been fixed in this PR and optimized this PR in the original websocket implementation. The bug is caused by concurrent mutation of the |
is this part of any react-native releases so far? |
It was released on 0.68 |
There was already reported and it's mark as resolved, see: #23825. But in fact this problem is still persist on iOS. After many investigation the problem comes from iOS RN WebSocket library.
Description
Server disconnect client on control packets, so if ping is disabled from server, problem disappear.
Error from server based on NodeJS
This error appear when server send data and in parallel send control packets to client.
React Native version:
0.62.2
The text was updated successfully, but these errors were encountered: