无法将我的App服务器连接到FCM XMPP服务器

时间:2019-06-12 09:44:31

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

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

我已经注册了一个项目,并具有服务器密钥和发件人ID。我遵循https://firebase.google.com/docs/cloud-messaging/auth-server#authorize_an_xmpp_connection

中的注释

我所有的代码都使用openssl编写在C语言中。

以下是我的App Server与FCM-XMPP Server之间的通信 将App 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服务器通信的App服务器。我正在运行基本相同的代码,我得到了

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

1 个答案:

答案 0 :(得分:0)

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

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

至少这是我自己实现的客户的情况。

相关问题