Hi guys, someone can help me with this problem?
when i push my project into balenaOS, i receive this errror.
i try put the ip defined in compose-yml but i receve the same error, then i try with the id from balena scan.
WebSocket connection to ‘ws://34880ba.local:4000/graphql’ failed: WebSocket is closed before the connection is established
this is my code
import { ApolloClient, InMemoryCache } from ‘@apollo/client’;
import { WebSocketLink } from ‘@apollo/client/link/ws’;
import { split, HttpLink } from ‘@apollo/client’;
import { getMainDefinition } from ‘@apollo/client/utilities’;
const http = new HttpLink({
uri: 'http://172.25.0.88:4000/graphql'
});
// window.location.protocol === ‘https:’ ? ‘wss’ : ‘ws’
const protocol = window.location.protocol === ‘https:’ ? ‘wss://’ : ‘ws://’;
const wsLink = new WebSocketLink({
uri: `${protocol}34880ba.local:4000/graphql`,
options: {
reconnect: true,
}
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === 'OperationDefinition' &&
definition.operation === 'subscription'
);
},
wsLink,
http,
);
const client = new ApolloClient({
link: splitLink,
cache: new InMemoryCache()
});
export default client;