阿波罗服务器-GraphQL';s订阅websocket连接不存在';不坚持

阿波罗服务器-GraphQL';s订阅websocket连接不存在';不坚持,graphql,apollo-server,graphql-subscriptions,Graphql,Apollo Server,Graphql Subscriptions,我一直在使用graphql订阅并能够实现它。当我在本地主持同样的节目时,它工作得很好,没有任何问题。但是,当我将它部署在空闲超时设置为“x”秒的服务器上时,它会在这些“x”秒之后断开与graphql Playerd上客户端的连接。我希望它能持续下去 这是我的密码 consthttp=require('http'); const{ApolloServer,gql}=require('apollo-server-express'); const express=require('express');

我一直在使用graphql订阅并能够实现它。当我在本地主持同样的节目时,它工作得很好,没有任何问题。但是,当我将它部署在空闲超时设置为“x”秒的服务器上时,它会在这些“x”秒之后断开与graphql Playerd上客户端的连接。我希望它能持续下去

这是我的密码

consthttp=require('http');
const{ApolloServer,gql}=require('apollo-server-express');
const express=require('express');
const db=require('./db');
const{PubSub,withFilter}=require('graphql-subscriptions')
const env=require('./config');
const cors=需要(“cors”);
const pubSub=新的pubSub();
常量app=express();
应用程序使用(cors());
常量typeDefs=gql`
类型查询{
qflEventTypes:[字符串]
}
类型突变{
pushQflData(符号:字符串,日期:Int,字段:字符串,值:字符串,类型:字符串):布尔值
pushQflDBEvent(事件:字符串,日期:Int,因子:字符串):布尔值
}
类型订阅{
qflDataChange:qflData
qflEventChange(事件名称:字符串):qflEvent
}
类型qflData{
符号:字符串
日期:Int
字段:字符串
值:字符串
类型:字符串
}
类型Qflent{
事件:字符串
日期:Int
因子:字符串
}
`;
常量解析程序={
查询:{
qflEventTypes(){
返回db.qflevents.list().map(a=>a.eventname);
}
},
突变:{
pushQflData:(根,{symbol,date,field,value,type})=>{
publish('QFL_DATA_change',{qflDataChange:{symbol,date,field,value,type}})
返回true;
},
pushQflDBEvent:(根,{事件,日期,因子})=>{
publish('QFL_EVENT_change',{qflEventChange:{EVENT,date,factor}})
返回true;
}
},
订阅:{
qflDataChange:{
subscribe:()=>pubSub.asyncierator('QFL\u DATA\u CHANGED')
},
qflEventChange:{
订阅:withFilter(()=>pubSub.asyncIterator('QFL_事件_更改'),(有效负载,变量)=>{
返回payload.qflEventChange.event==variables.eventname;
})
}
}
};
const server=新服务器({
typeDefs,
解析器,
内省:true,//启用架构的内省
操场:true,//启用实际操场
订阅:{
路径:'/api/ws',
keepAlive:15000,
onConnect:()=>console.log(“已连接”),
onDisconnect:()=>console.log(“断开”)
}
});
applyMiddleware({app,路径:'/api/ql',cors:false});
const httpServer=http.createServer(app);
installSubscriptionHandlers(httpServer);
var port=env.Runtime.port | | 9000
httpServer.listen(端口,()=>{

log(`
keepAlive
setInterval
的一个参数-以毫秒为单位缩放…1000太低了;)我实际上也尝试了更长的时间间隔15000 20000,仍然相同的问题不会太多…
keepAlive
setInterval
的一个参数-以毫秒为单位缩放…1000太低;)我实际上也尝试了更长的时间间隔15000 20000,仍然相同的问题不会太多。。。