This repository was archived by the owner on Sep 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Could not connect to WebSocket endpoint #28
Copy link
Copy link
Open
Description
Hi, I'm running a Meteor/React/Apollo/Graphql stack and I'm trying to get subscriptions working, I've looked through the Apollo docs and have tried to get it working with this library but I'm getting an error in my Graphiql console as such:
{
"error": "Could not connect to websocket endpoint ws://XXX.XXX.XX.XX:3000/subscriptions. Please check if the endpoint url is correct."
}
My server code is as follows:
import { ApolloServer, gql } from "apollo-server-express"
import { makeExecutableSchema } from "graphql-tools"
import { WebApp } from "meteor/webapp"
import { getUser } from "meteor/apollo"
import merge from "lodash/merge"
import SchemaA from "../../api/a/SchemaA.graphql"
import ResolverA from "../../api/a/resolvers"
import SchemaB from "../../api/b/SchemaB.graphql"
import ResolverB from "../../api/b/resolvers"
import SchemaC from "../../api/c/SchemaC.graphql"
import ResolverC from "../../api/c/resolvers"
import { GooglePubSub } from "@axelspringer/graphql-google-pubsub"
const pubsub = new GooglePubSub()
const typeDefs = [SchemaA, SchemaB, SchemaC]
const resolvers = merge(ResolverA, ResolverB, ResolverC)
const schema = makeExecutableSchema({ typeDefs, resolvers })
const server = new ApolloServer({
schema,
context: async ({ req }) => ({
user: await getUser(req.headers.authorization),
pubsub
}),
subscriptions : {
path: '/subscriptions'
}
})
server.applyMiddleware({
app: WebApp.connectHandlers,
path: "/graphql",
})
WebApp.connectHandlers.use("/graphql", (req, res) => {
if (req.method === "GET") {
res.end()
}
})
I had initially tried this exact setup with the Redis pubsub alternative but I was getting the following error in my terminal:
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379
}
I'm not getting this error anymore with GooglePubSub, but the first error thrown in Graphiql still persists. Does anyone have any recommendations on how to go about fixing this? There's clearly some configuration/setup which I'm not doing correctly.
Metadata
Metadata
Assignees
Labels
No labels