useSubscription Socket errors being thrown in the console

Hello, I hope you are doing well!

We are using web sockets in our website with graphQL hence we are using useSubscription.

It is working fine, I get the data back when I need it; however, we are facing a small issue that while it is not stopping our website from functioning, it is extremely weird and awkward for users using the website.

Basically, randomly, without any call from the backend web socket the useSubscription sometimes throws multiple errors in the console at no specific time, very randomly.

There are 2 errors:

The first one is:

WebSocket connection to URL failed: Insufficient resources.

The second one is:

WebSocket connection to URL failed: WebSocket is closed before the connection is established.

With URL being replaced with our backend WebSocket URL.

We know that the URL is valid since it works perfectly fine and we get data when needed. However, this error is weird since we get it at random times without any call from the backend web socket.

Thank You a lot for your help in advanced!

Hi Maya,

these errors are thrown by your Websocket library, so depending on the implementation you are using either subscriptions-transport-ws or graphql-ws.

There is not really something from Apollo side we can do to look into that - maybe you can bring that up with the library you are using there?