Could Not Connect To Websocket Endpoint Ws. Please Check If The Endpoint Url Is Correct. Code Example


Example: could not connect to websocket endpoint ws://localhost:4000/graphql. please check if the endpoint url is correct.


The it turns out that Firefox has issues with websockets (see this bug report that has been re-appeared even after the supposed fix).

In Firefox it works directly after starting a novel browser but after some hot reloading it stops working. The following helps out with starting out fresh but not with the reloading issue:

const wsLink = new WebSocketLink({
uri: SUBSCRIPTION_URI,
options: {
reconnect: true,
timeout: 20000,
lazy: true,
},
});

window.addEventListener('beforeunload', () => {
// @ts-ignore - the function is private in typescript
wsLink.subscriptionClient.close();
});
I think the bug is related to this SO-question: "websocket was interrupted while page is loading" on Firefox for Socket.io

If you want to test different solutions I've created an example repo: https://github.com/gforge/subscription_example that works both by itself and with a Docker container.

Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy