Firebase 上游云消息
Firebase upstream cloud messages
我已经使用 this nodeJS 包设置了 XMPP 服务器。我可以很好地发送下游消息(从 XMPP 服务器到设备),但是当我尝试发送上游消息时,服务器很少收到它。
服务器上处理上游消息的代码是:
xcs.on('message', function(messageId, from, data, category) {
console.log("Got msg")
console.log(arguments)
});
在 android 工作室中,我使用以下方式发送上游消息:
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());
}
使用 print 语句我看到发送函数确实被调用并且在我发送时没有错误但是节点服务器没有收到任何东西。我会注意到服务器有时会收到上游消息,但在将近 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
不知道是android客户端的问题还是节点服务器的问题。感谢您的帮助。
问题是我使用 AWS Lambda 来托管 XMPP 服务器,认为我只能在需要时打开它。 XMPP 服务器需要处于服务器设置(它可以保持打开状态)而不是关闭和打开。细节超出我的范围。
我已经使用 this nodeJS 包设置了 XMPP 服务器。我可以很好地发送下游消息(从 XMPP 服务器到设备),但是当我尝试发送上游消息时,服务器很少收到它。
服务器上处理上游消息的代码是:
xcs.on('message', function(messageId, from, data, category) {
console.log("Got msg")
console.log(arguments)
});
在 android 工作室中,我使用以下方式发送上游消息:
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());
}
使用 print 语句我看到发送函数确实被调用并且在我发送时没有错误但是节点服务器没有收到任何东西。我会注意到服务器有时会收到上游消息,但在将近 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
不知道是android客户端的问题还是节点服务器的问题。感谢您的帮助。
问题是我使用 AWS Lambda 来托管 XMPP 服务器,认为我只能在需要时打开它。 XMPP 服务器需要处于服务器设置(它可以保持打开状态)而不是关闭和打开。细节超出我的范围。