Sunday, 31 March 2019

Subscriptions are not stable. Prisma terminates with a GqlConnectionTerminate error

I just implemented subscriptions in my API which use graphql-yoga. I have one prisma server which have the following config:

databases:
  default:
    connector: postgres
    host: 
    database: prisma
    port: 5432
    user: admin
    password: ${DB_PASSWORD}
    migrations: true
    rawAccess: true
    ssl: true
    connectionLimit: 5

Note that I have limited the number of connections because I'm connecting to a Google Cloud SQL instance which have limited number of allowed connections. Now I have 4 yoga apps connecting to this one prisma server. The problem is, sometimes the subscriptions work and sometimes it throws the following error (In the playground):

{
  "error": "Could not connect to websocket endpoint wss://yourapi.com/subscriptions. Please check if the endpoint url is correct."
}

When I check the prisma container logs, I found this:

Deployment worker initialization complete.
Version is up to date.
[SubscriptionSessionActor] Received unknown message: com.prisma.subscriptions.protocol.SubscriptionProtocolV07$Requests$GqlConnectionTerminate$@494aa66a
Killed
Obtaining exclusive agent lock...
Initializing workers...
Obtaining exclusive agent lock... Successful.
Successfully started 1 workers.
Server running on :4466

My APIs are behind an Nginx proxy:

server {
  server_name example.com;
  listen 443 ssl http2;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header X-Custom-Referrer "idToken";
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_max_temp_file_size 0;
    proxy_pass http://127.0.0.1:4050;
    proxy_redirect off;
    proxy_read_timeout 240s;
  }


    ssl_certificate ___ # managed by Certbot
    ssl_certificate_key ___ # managed by Certbot
}

I can't figure it out where is the issue. Any clue or guidance will be much appreciated. Thanks in advance.



from Subscriptions are not stable. Prisma terminates with a GqlConnectionTerminate error

No comments:

Post a Comment