In case anyone sees this: I figured it out. All of the code above will work just fine to connect to GCM. My companies corporate firewall was blocking the port. In retrospect I should have checked this sooner.
Unable to connect to GCM using agsXMPP (No connection could be made because the target machine actively refused it)
-
31-07-2022 - |
문제
I've been trying for about a day to just open an XMPP connection to GCM using the agsXMPP library. I'm new to the library and XMPP in general so its entirely possible i'm making a silly mistake. The only other thing that I know could be the problem is that my project has not yet been whitelisted by google, but I had read elsewhere that you should still be able to connect initially. My code is as follows:
class Program
{
static void Main(string[] argus)
{
XmppClientConnection xmpp = new XmppClientConnection();
xmpp.UseSSL = true;
xmpp.UseStartTLS = false;
xmpp.Server = "gcm.googleapis.com";
xmpp.ConnectServer = "gcm.googleapis.com";
xmpp.Port = 5235;
xmpp.Password = "My Api Key";
xmpp.Username = "My Project Id";
xmpp.OnAuthError += OnAuthError;
xmpp.OnError += OnError;
xmpp.OnSocketError += new ErrorHandler(objXmpp_OnSocketError);
xmpp.Open();
// Just to keep the app open
while (true)
{
System.Threading.Thread.Sleep(100);
}
}
static void objXmpp_OnSocketError(object sender, Exception ex)
{
return;
}
static void OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
{
return;
}
static void OnError(object sender, Exception ex)
{
return;
}
}
What ends up happening is that i hit the SocketError with the following error:
No connection could be made because the target machine actively refused it 74.125.20.188:5235
Is this because I have yet to be whitelisted, or is there more that I can do with agsXMPP settings? Any help is appreciated.
EDIT: Project was whitelisted, unfortunately I am still getting the same error. So that rules that out as a cause.
올바른 솔루션이 없습니다
다른 팁