在调用pushMessageByUids后报错,是什么原因?

[2017-02-08 10:13:13.144] [DEBUG] pomelo - [\node_modules\pomelo\lib\common\service\channelService.js] [gs-server-1] channelService sendMessageByGroup route: push, msg: {"message":"hahaha"}, groups: {"connector-server-1":["lee"]}, opts: null

[2017-02-08 10:13:13.147] [ERROR] pomelo-rpc - [mqtt-acceptor] process rpc message error TypeError: app.rpcInvoke is not a function
at \node_modules\pomelo\lib\common\service\channelService.js:434:13
at sendMessage (\node_modules\pomelo\lib\common\service\channelService.js:437:7)
at sendMessageByGroup (\node_modules\pomelo\lib\common\service\channelService.js:444:7)
at ChannelService.pushMessageByUids (\node_modules\pomelo\lib\common\service\channelService.js:121:3)
at Object.module.exports.push (\app\util\channelUtil.js:24:20)
at Handler.push (\app\servers\gs\handler\testHandler.js:76:17)
at Service.handle (\node_modules\pomelo\lib\common\service\handlerService.js:59:20)
at handle (\node_modules\pomelo\lib\server\server.js:375:25)
at next (\node_modules\pomelo\lib\common\service\filterService.js:50:7)
at Service.beforeFilter (\node_modules\pomelo\lib\common\service\filterService.js:65:3)
at beforeFilter (\node_modules\pomelo\lib\server\server.js:242:8)
at doHandle (\node_modules\pomelo\lib\server\server.js:388:3)
at pro.handle (\node_modules\pomelo\lib\server\server.js:125:3)
at pro.handle (\node_modules\pomelo\lib\components\server.js:67:14)
at Remote.forwardMessage (\node_modules\pomelo\lib\common\remote\backend\msgRemote.js:45:10)
at pro.route (\node_modules\pomelo\node_modules\pomelo-rpc\lib\rpc-server\dispatcher.js:52:10)

[2017-02-08 10:13:13.150] [ERROR] pomelo - [\node_modules\pomelo\lib\server\server.js] fail to process remote message:TypeError: app.rpcInvoke is not a function
at \node_modules\pomelo\lib\common\service\channelService.js:434:13
at sendMessage (\node_modules\pomelo\lib\common\service\channelService.js:437:7)
at sendMessageByGroup (\node_modules\pomelo\lib\common\service\channelService.js:444:7)
at ChannelService.pushMessageByUids (\node_modules\pomelo\lib\common\service\channelService.js:121:3)
at Object.module.exports.push (\app\util\channelUtil.js:24:20)
at Handler.push (\app\servers\gs\handler\testHandler.js:76:17)
at Service.handle (\node_modules\pomelo\lib\common\service\handlerService.js:59:20)
at handle (\node_modules\pomelo\lib\server\server.js:375:25)
at next (\node_modules\pomelo\lib\common\service\filterService.js:50:7)
at Service.beforeFilter (\node_modules\pomelo\lib\common\service\filterService.js:65:3)
at beforeFilter (\node_modules\pomelo\lib\server\server.js:242:8)
at doHandle (\node_modules\pomelo\lib\server\server.js:388:3)
at pro.handle (\node_modules\pomelo\lib\server\server.js:125:3)
at pro.handle (\node_modules\pomelo\lib\components\server.js:67:14)
at Remote.forwardMessage (\node_modules\pomelo\lib\common\remote\backend\msgRemote.js:45:10)
at pro.route (\node_modules\pomelo\node_modules\pomelo-rpc\lib\rpc-server\dispatcher.js:52:10)

标签: pomelo 开发求助
lwbsyz 在 2-8 10:21发布 分享到 weibo
2 回复
#1 fantasyni 2-8 16:50 回复

这个错误不可能的啊

app.rpcInvoke is not a function

#2 {2} fantasyni 2-8 16:50 回复
lwbsyz 2-8 16:55 回复

刚刚找到原因了,是因为在adminServer.json中没有添加服务器类型gs,所以这类服务器连接master失败,报个错:
pomelo-admin - [MonitorAgent] server "gs-server-1" "gs" register master failed
pomelo-admin - [MqttClient] mqtt socket is disconnect, remote server host: 127.0.0.1, port: 3005
这个错,好像会导致afterStart方法无法被调用,所以这句就执行不到。
this.app.set('rpcInvoke', this.client.rpcInvoke.bind(this.client), true);
所以gs类型的服务器,在调用pushMessageByUids时就会报上面的错误了。

fantasyni 2-8 18:11 回复

@lwbsyz 恩恩

回到顶部