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

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable