【问题标题】:Unable to Connect my App Server to FCM XMPP Server无法将我的应用服务器连接到 FCM XMPP 服务器
【发布时间】:2019-06-12 09:44:31
【问题描述】:

我正在尝试使用 Openssl TLS 连接到 FCM XMPP 服务器

我已经注册了一个项目并拥有一个服务器密钥和发件人 ID。我按照https://firebase.google.com/docs/cloud-messaging/auth-server#authorize_an_xmpp_connection中的注释进行操作

我所有的代码都在 C 中使用 openssl。

以下是我的 App Server 和 FCM-XMPP Server 之间的通信 应用服务器到 FCM-XMPP:

<stream:stream to='fcm-xmpp.googleapis.com' version='1.0' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>

来自 FCM-XMPP 服务器:

<stream:stream from="fcm-xmpp.googleapis.com" id="E1204B9D567A6A8A" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
<stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>

应用服务器到 FCM-XMPP:

<auth mechanism='PLAIN' xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>base 64 encoding of <null>sendID@fcm-xmpp.googleapis.com<null>serverKey</auth>

来自 FCM-XMPP 服务器:

<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>

我有一个与 GCM-XMPP 服务器通信的应用服务器。我运行基本相同的代码,我得到了

<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>

【问题讨论】:

    标签: c firebase openssl firebase-cloud-messaging xmpp


    【解决方案1】:

    FCN-XMPP 的应用服务器应该是:

    <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'></auth>
    

    然后服务器将响应一个空字符串。这是您现在发送编码数据的信号:

    <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">encodedData</response>
    

    encodedData 应该是以下的编码版本:
    \0sendID@fcm-xmpp.googleapis.com\0serverKey

    如果成功,您将收到成功标签。

    至少所有这些都是我自己实现的客户端的情况。

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 2015-11-20
      相关资源
      最近更新 更多