我刚刚在我的 API 中实现了使用 graphql-yoga 的订阅。我有一台具有以下配置的 prisma 服务器:
databases:
default:
connector: postgres
host:
database: prisma
port: 5432
user: admin
password: ${DB_PASSWORD}
migrations: true
rawAccess: true
ssl: true
connectionLimit: 5
请注意,我限制了连接数,因为我正在连接到允许连接数有限的 Google Cloud SQL 实例。现在我有 4 个瑜伽应用程序连接到这台 prisma 服务器。问题是,有时订阅有效,有时会引发以下错误(在操场上):
{
"error": "Could not connect to websocket endpoint wss://yourapi.com/subscriptions. Please check if the endpoint url is correct."
}
当我检查 prisma 容器日志时,我发现:
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
我的 API 在 Nginx 代理后面:
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
}
我无法弄清楚问题出在哪里。任何线索或指导将不胜感激。提前致谢。