【问题标题】:Firebase upstream cloud messagesFirebase 上游云消息
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

    • 这方面有什么更新吗?文档说 XMPP 服务器可以使用 Cloud Functions(基本上是 AWS Lambda)来实现。 Docs :“您的应用服务器或运行您的服务器逻辑的其他受信任的服务器环境,例如 Cloud Functions for Firebase 或其他由 Google 管理的云环境。” firebase.google.com/docs/cloud-messaging/…
    猜你喜欢
    • 2018-09-07
    • 1970-01-01
    • 2022-12-21
    • 1970-01-01
    • 2016-12-05
    • 2019-07-12
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多