I actually was having this same issue and found it was related to how my sever port was starting and how I had my Apollo Provider configured on my FE. Note "ws" did not work and it required "wss" to work for me as well. I was not directing anything to a specific url like you are with "/subscriptions".instead im just using whatever URI Heroku/localhost provides me
Server GraphQLServer code:
const server = new GraphQLServer({
typeDefs,
resolvers,
context: { pubsub, endpoint: "/" },
});
Server start code:
server.start(({ port }) => {
console.log(`Server listening on ${port} for incoming requests`);
});
FE Apollo Provider Config
const httpLink = new HttpLink({
uri: "https://domainName.herokuapp.com,
});
const wsLink = new WebSocketLink({
uri: "wss://domainName.herokuapp.com/",
options: {
reconnect: true,
},
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === "OperationDefinition" &&
definition.operation === "subscription"
);
},
wsLink,
httpLink
);
const client = new ApolloClient({
link: splitLink,
uri: "https://domainName.herokuapp.com",
cache: new InMemoryCache({
addTypename: false,
}),
});
Hopefully this helps you out and gets you moving forward. took a half a day to figure out myself. I assume it may be the same situation for you just a little different for your situation. Happy coding!!!