-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Hasura WebSocket closed before connection is established error while trying to create subscription #4509
Comments
Hello any update on this? I was able to reproduce this on your demo site as well (https://realtime-poll.demo.hasura.app/console) |
Any update, please? |
Experiencing the same issue currently. Running 1.3.1. |
Same issue. ver 1.3.2 |
I got the same issue and so far I have been working around it by switching the browser. |
Switching the browser is not a solution, actually. Any updates? I'm establishing connection with Apollo client, by the way. Anyone else? |
Confirmed, I'm seeing this issue when I use Brave, although not when I use Chrome. My setup is a local docker-compose with port 8083(host):8080(client). |
Hello @vmironichev , Thanks for submitting the issue! I was trying to reproduce this issue with the console on chrome, firefox & Brave. I could not reproduce this issue with the following steps
Can any of you share the steps where you faced this issue? |
I was seeing the same issue because our application was replacing Hasura Cloud endpoint Therefore, people self-hosting Hasura and not handling SSL should be using |
Double check the hostname, this is the error you'll get if you try to connect to a hostname that doesn't exist. |
Same here.
client > at first attempt > WebSocket is closed before the connection is established. (status: Finished) |
I have the same issue. It works in private mode - both local and production First I though is client issue: apollographql/subscriptions-transport-ws#377 and tried to resolve it with SubscriptionClient.prototype.createMaxConnectTimeGenerator = function() {
return {
duration() {
return WS_TIMEOUT // mine is at 60000
},
reset() {
// noop
},
}
} but it did not have any affect Hasura v1.3.1(prod)1.3.2(local). |
Any solutions? I'm also getting the same issue |
both with "@apollo/client": "^3.3.3" in nextjs, and with the hasura console 1.3.3 and 1.3.4.beta.1, and 1.3.4.beta 2 with Brave Version 1.17.73 Chromium: 87.0.4280.67 (Official Build) (64-bit) on Linux PopOs 20.04, randomly in a subscription , I have the problem of: On Firefox 84.0b4 (64-bit) works fine all time. (i tried one time in Google Chrome Version 87.0.4280.66 (Official Build) (64-bit) and its works) if... i do a my docker-compose.yml file:
.env file for docker-compose
will it be a brave or hasura problem? |
Also have this issue. Running on localhost for Hasura Cloud. declaring ApolloClient like this: import { ApolloClient, HttpLink, split } from "@apollo/client";
import { WebSocketLink } from "@apollo/client/link/ws";
import { getMainDefinition } from "@apollo/client/utilities";
import { cache } from "./cache";
export const apolloClientCreator = (token) => {
let headers = token
? {
"content-type": "application/json",
Authorization: `Bearer ${token}`,
}
: {
"content-type": "application/json",
};
const httpLink = new HttpLink({
uri: process.env.REACT_APP_GRAPHQL_HTTPS_ENDPOINT,
headers,
});
const wsLink = new WebSocketLink({
uri: process.env.REACT_APP_GRAPHQL_WS_ENDPOINT,
options: {
reconnect: true,
connectionParams: { headers },,
},
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return definition.kind === "OperationDefinition" && definition.operation === "subscription";
},
wsLink,
httpLink
);
return new ApolloClient({
link: splitLink,
cache: cache(),
});
}; |
@Spark3000 In what context are you? (browser,SO,etc). The error appears in all browsers? or Only Brave Browser? |
I am also experiencing hang time on websockets in Brave. Developing on localhost with a free tier of Hasura Cloud, frontend developed with React, Apollo Client, and Auth0 SPA. The connection is eventually established, and the actual query takes about 30ms to complete per Hasura Logs. Once the connection is made, subsequent queries are relatively quick. I've tested in Firefox and Chrome and have not experienced the same amount of network hangtime or websocket errors as in Brave. Not 100% positive whether this is something server side, or if Brave browser is fudging up my websocket connections before they reach the server, but it appears to be the same issue posted here. |
Only tested on Chrome latest on Mac OS 10.15. I’ve tried multiple configs in setting up the ApolloClient and can’t get rid of it. I’m using Create-React-App with a standard no-vpn public DNS network setup. Leads me to think it’s a server side thing. |
Hey folks, I am unable to consistently reproduce this. I had that warning about the socket connection being closed once, but it didn't seem to impact the data being loaded and then I couldn't seem to reproduce it again. Although, one Apollo setting may be necessary to prevent this warning from happening:
We had another user facing this issue report that this resolved it for them. So here I have enabled this in my WS Link constructor options: const wsLink = new WebSocketLink({
uri: HASURA_WEBSOCKET_ENDPOINT,
options: {
reconnect: true,
lazy: true, // <--- HERE
connectionParams: { headers }
}
}) Please have a look at the code in my repro attempt here (copied from @Spark3000's code): And then the main app page: |
Thanks @GavinRay97 ! |
I get this a ton when using Brave. If I restart the browser if goes away for a while, until it eventually comes back. |
This is still happening quite frequently on Brave, I filled an issue: brave/brave-browser#15410 maybe those affected (@phishy) could comment / confirm there as well? thank you Would be great if they finally looked into this... I think I'm switching from Brave for time being because of this issue. |
Is anyone seeing this error on a client other than Apollo? |
Yes, I'm mostly seeing on websites I'm developing. It happens rarely enough that I don't see it on other sites but I'm 99.9% sure it's issue in Brave since it doesn't happen in Chrome and it always works again from incognito mode or after browser restart and my code doesn't change in between. Another confirmation are reports here and at some other places. It's sporadic but very annoying and almost definitely has to do with Brave / Chromium (?)... any other problems on top are possibly separate inside webapps... but most of them use some websocket library and with good coding such issues where basic connection is a problem shouldn't happen. |
SOLVED: Set inactivityTimeout in a good timeout
Versions: NOTICE: |
I am seeing this intermittently in my self-hosted Hasura server using Apollo in Chrome. It worked in Safari at the same time. POST-style GraphQL queries also succeeded from the same browser. The same browser failed in the same way against a staging server on a different hostname. Deleting cookies and local storage in the browser had no effect. Quitting Chrome and restarting it made the issue stop reproducing. Chrome macOS: Client libs:
Hasura:
|
Don't if this will help anyone but here it goes: When working Hope this helps someone. |
Have this same issue, Hasura is running in kubernetes NodePort. HTTPS works just fine. WSS doesnt work even in the hasura console. v2.9.0 |
Thanks for reporting this and providing more info. We are looking into this and will keep you posted. |
Hey folks, there are multiple scenarios where such an error can be thrown. For instance:
I am closing this ticket because of the above discussions and resolutions. If you have a different scenario where this error is thrown, then feel free to open a new ticket with details on reproducing it. |
Same issue here, Hasura WebSocket closing before the connection is established, but this problem seemed to be only on Brave browser. |
Thanks it work! ,wss not working with https://domain.com/v1/graphql .I using ws http://ip domain:8080/v1/graphql it working! |
Hello, we are using Hasura GraphQL engine for querying and subscriptions using web sockets, some times we are seeing errors with invalid timestamp pointing to some date from 1970 (random day/month/time) while trying to establish subscription. Hasura client (Web UI) can do a lot of reconnect attempts until it subscribes for the data (please see attached screenshot). Can you please advice, is it configuration/infrastructure issue or a bug? Thanks!
Hasura version 1.1.1 running in EKS
Postgres 11
The text was updated successfully, but these errors were encountered: