我刚刚在我的API中实现了使用graphql-yoga的订阅。我有一台棱镜服务器,其配置如下:
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个Yoga应用程序连接到这台棱镜服务器。问题是,有时订阅工作正常,有时会引发以下错误(在操场上):
{
"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
}
我不知道问题出在哪里。任何线索或指导将不胜感激。预先感谢。