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

Node server keeps crashing repeatedly with "Error: reserved fields must be empty" #1039

Closed
booboothefool opened this issue Mar 10, 2017 · 4 comments

Comments

@booboothefool
Copy link

booboothefool commented Mar 10, 2017

This started happening suddenly, and now I can't even get my server back up. It's been a few hours. it just restarts, then immediately crashes.

screen shot 2017-03-09 at 6 52 02 pm

Any ideas?

@lpinca
Copy link
Member

lpinca commented Mar 10, 2017

Add an error listener to your WebSocket objects and handle the error.

wss.on('connection', (ws) => {
  ws.on('error', (err) => handleError(err));
});

This error is raised when the client sends a frame with one or more reserved bit on. It can happen because the client is broken or because a bad actor is sending invalid frames with the aim of crashing your server.

@booboothefool
Copy link
Author

booboothefool commented Mar 10, 2017

@lpinca Do you have any advice on how to implement this with this library?

https://github.com/apollographql/subscriptions-transport-ws

It looks like I'd do something like this:

new SubscriptionServer(
  {
    subscriptionManager,
    keepAlive: 20000,
    onConnect: async (connectionParams, webSocket) => {
      webSocket.on('error', err => console.error(err));
    },
  },
  {
    server: websocketServer,
    path: '/',
  }
);

which does not seem to be helping as the server continues to crash with "reserved fields must be empty".

@lpinca
Copy link
Member

lpinca commented Mar 10, 2017

What you wrote in this comment apollographql/subscriptions-transport-ws#94 (comment) seems correct to me. There should be an error listener there.

@booboothefool
Copy link
Author

booboothefool commented Mar 10, 2017

@lpinca Yes, after I made sure the change was in:

Wrong:

new SubscriptionServer(
  {
    subscriptionManager,
    keepAlive: 20000,
    onConnect: async (connectionParams, webSocket) => {
      webSocket.on('error', err => console.error(err));
    },
  },
  {
    server: websocketServer,
    path: '/',
  }
);

Correct:
https://github.com/apollographql/subscriptions-transport-ws/blob/master/src/server.ts#L96

            request.on('error', function (err) {
                console.error(err);
            });

It is catching the error, and no longer crashing. All is well now. Thanks so much.

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