Auth错误连接到谷歌云消息传递云连接服务器

时间:2016-05-07 09:07:03

标签: push-notification google-cloud-messaging xmpp agsxmpp

我是gcm上游消息传递的新手。我正在尝试通过xmpp连接到云连接服务器(使用c#agsxmpp库)。但是,我从服务器收到一条未经授权的错误消息,即使相同的项目编号/ api密钥用于http下游推送通知,连接也会立即关闭。任何帮助表示赞赏。

这是代码。

        var username = Configuration.PROJECT_NUMBER + "@" + Configuration.GCM_SERVER;
        xmpp = new XmppClientConnection
        {
            UseSSL = true,
            UseStartTLS = false,
            Server = Configuration.GCM_SERVER,
            ConnectServer = Configuration.GCM_SERVER,
            Port = Configuration.GCM_PORT,
            Username = username,
            Password = Configuration.GCM_API_KEY,
            AutoResolveConnectServer = true,
            SocketConnectionType = SocketConnectionType.Direct,
            AutoAgents = false,
            KeepAlive = true,
            AutoRoster = false,
            AutoPresence = false,
            UseCompression = false,
            Show = ShowType.chat
        };

        xmpp.OnReadSocketData += Xmpp_OnReadSocketData;
        xmpp.OnWriteSocketData += Xmpp_OnWriteSocketData;
        xmpp.OnLogin += Xmpp_OnLogin;
        xmpp.OnMessage += Xmpp_OnMessage;
        xmpp.OnError += Xmpp_OnError;
        xmpp.OnClose += Xmpp_OnClose;
        xmpp.OnAuthError += Xmpp_OnAuthError;

        xmpp.Open();

    }

这是与ccs的交互(从OnReadSocketData和OnWriteSocketData事件中捕获)

To CCS<<11:59:58 834
<stream:stream to='gcm.googleapis.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

From CSS>> 11:59:59 037
<stream:stream from="gcm.googleapis.com" id="AF8BBDE576QWEFF3543" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">                                                                                                                                                                                                                                                                                                                                                                                         


From CSS>> 11:59:59 101
<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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   


To CCS<<11:59:59 115
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">ADIwNjAxOTEwOTA2Mlw0MGjkdf4y67fvbjjdgESnhaa2tFX3hIcm56NXhWZndJclpFUmlMbnBqNVFIdkk=</auth>


From CSS>> 11:59:59 312
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>ism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features> 


From CSS>> 11:59:59 314
</stream:stream>urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>ism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>                

1 个答案:

答案 0 :(得分:1)

我将用户名从<Project_Number>@<GCM_Server_Address>更改为<Project_Number>,但它正在运行。