1
我是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我從<Project_Number>@<GCM_Server_Address>
只是<Project_Number>
更改用戶名的相互作用(從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>
你說你剛剛使用GCM上游消息傳遞的新功能,我是否正確地假設你正在實施的這一切都只是爲了試用它?你正在使用'gcm-preprod.googleapis.com:5236'端口,那樣的東西?只是想驗證'Configuration.PROJECT_NUMBER' =''?乾杯。 –
找到了[相似文章](http://stackoverflow.com/q/32887244/4625829)。幾乎沒有差別:實施的語言和我以前的評論,他使用'gcm-preprod.googleapis.com'。我繼續問他是否能找到導致他錯誤的原因。我不知道這是否有用。讓我們來看看。乾杯! –
感謝您的幫助,我使用<項目編號> @作爲用戶名,我將其更改爲僅用戶名,現在正在工作。 –
Yohannes