【发布时间】:2017-03-06 01:08:35
【问题描述】:
我已经使用 this nodeJS 包设置了 XMPP 服务器。我可以很好地发送下游消息(从 XMPP 服务器到设备),但是当我尝试发送上游消息时,服务器很少收到它。
服务器上处理上游消息的代码是:
xcs.on('message', function(messageId, from, data, category) {
console.log("Got msg")
console.log(arguments)
});
在 android studio 中,我使用以下方式发送上游消息:
public void send(ArrayList<String> messages) {
System.out.println("Attempting to send");
FirebaseMessaging fm = FirebaseMessaging.getInstance();
System.out.println("msgId: " + msgId.get());
RemoteMessage.Builder rm = new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com")
.setMessageId(Integer.toString(msgId.incrementAndGet()));
for (int i = 0; i < messages.size(); i++) {
rm.addData(String.valueOf(i), messages.get(i));
}
fm.send(rm.build());
}
使用打印语句,我看到确实调用了发送函数,发送时没有错误,但节点服务器什么也没收到。我会注意到服务器有时会收到上游消息,但它在近 50 次尝试中只有一次。
以下是我从服务器接收到消息然后尝试发回上游消息时得到的一些调试器输出:
V/FA: Session started, time: 3115366
I/FA: Tag Manager is not found and thus will not be used
D/FA: Logging event (FE): _s, Bundle[{_o=auto, _sc=MainActivity, _si=8922817241262257215}]
V/FA: Using measurement service
V/FA: Connecting to remote service
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 1
V/FA: Inactivity, disconnecting from the service
I/System.out: Receieved message:
I/System.out: Key = TYPE, Value = TEXT
I/System.out: Key = ACTION, Value = GET
I/System.out: Attempting to send
不知道是安卓客户端的问题还是节点服务器的问题。感谢您的帮助。
【问题讨论】:
标签: node.js firebase google-cloud-messaging firebase-cloud-messaging