pomelo的服务器配置在项目中
config/servers.json中
"development":{
"connector":[
{"id":"connector-server-1", "host":"127.0.0.1", "port":4050, "clientPort": 3050, "frontend": true},
{"id":"cs2", "host":"127.0.0.1", "port":4050, "clientPort": 3051, "frontend": true}
],
"chat":[
{"id":"chat-server-1", "host":"127.0.0.1", "port":6050}
],
"gate":[
{"id": "gate-server-1", "host": "127.0.0.1", "clientPort": 3014, "frontend": true}
]
}
注意:带有
"clientPort": 3050, // 客户端连接时监听的端口
"frontend": true, // 前端服务器
的为前端服务器,这两个参数缺一不可。
为了使得客户端顺利的连接,在app.js的需要对所有的前端服务器进行协议设置
app.configure('production|development', 'connector', function(){
app.set('connectorConfig', // 注意,这里只能是这个'connectorConfig',其他值无效
{
connector : pomelo.connectors.hybridconnector,
heartbeat : 3,
useDict : true,
useProtobuf : true
});
});
希望童鞋们匆必要记信这些关键点,否则会出莫名奇妙的连接错误。
点击链接加入群【pomelo学习交流群】:https://jq.qq.com/?_wv=1027&k=5XNRFLl
本文深入探讨了使用Pomelo框架进行服务器配置的关键步骤,特别是如何在config/servers.json文件中设置前端服务器,并通过app.js进行协议配置。重点强调了前端服务器的识别与连接设置,确保客户端能顺利连接。文章还提供了实例代码和连接错误避免指南,帮助开发者高效完成配置。
1859

被折叠的 条评论
为什么被折叠?



