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客户端或节点服务器。谢谢你的帮助。

回答

0

问题在于我使用AWS Lambda托管XMPP服务器,认为我只能在需要时才能将其打开。 XMPP服务器需要处于服务器设置(它可以保持开启状态),而不是关闭和打开。细节超越了我。