1
我已經使用this nodeJS包設置了XMPP服務器。我可以發送一個下游消息(從XMPP服務器到設備),但是當我嘗試發送上游消息時,服務器很少收到它。Firebase上游雲消息
,處理上游消息在服務器上的代碼是:
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語句我看到發送功能確實做:
xcs.on('message', function(messageId, from, data, category) {
console.log("Got msg")
console.log(arguments)
});
在Android Studio中我使用發送上行消息被調用,當我發送時沒有錯誤,但節點服務器什麼也沒收到。我會注意到服務器SOMETIMES接收到上游消息,但它曾經接近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客戶端或節點服務器。謝謝你的幫助。