howtographql / react-apollo

MIT License
717 stars 319 forks source link

Firefox can’t establish a connection to the server at ws://localhost:4000/. #44

Closed ttnghia195 closed 5 years ago

ttnghia195 commented 6 years ago

I clone this repo and run it. But i have a problem, realtime subscription not working. Please help me!

itscarlosrufo commented 5 years ago

Thanks @ttnghia195 for opening this issue 😄. It should be working now. Closing this, please, feel free to re-open this issue if you cannot make it work!

kwoxer commented 4 years ago

I have the same issue. I cloned https://github.com/howtographql/react-apollo and did everything like the Readme says. Except the database connection.

For my connection I use MongoDB with:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.34
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            uri: 'mongodb://prisma:prisma@mongo'
  mongo:
    image: mongo:3.6
    restart: always
    # Uncomment the next two lines to connect to your your database from outside the Docker environment, e.g. using a database GUI like Compass
    # ports:
    # - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: prisma
      MONGO_INITDB_ROOT_PASSWORD: prisma
    ports:
      - "27017:27017"
    volumes:
      - mongo:/var/lib/mongo
volumes:
  mongo:

Everything works fine. But I just get...

WebSocket connection to 'ws://localhost:4000/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Chrome: grafik

Firefox: grafik

I'm not sure if I need to change the ports. But the readme does not say something like that. Also the https://github.com/howtographql/react-apollo/blob/master/server/prisma/prisma.yml is missing the endpoint.

What do I need to change to get the WebSocket connection working?