开发者

Why can't I connect to Google Talk in agsXMPP?

I'm trying to get started using agsXMPP, but I'm having some problems. I'm trying to run this code:

using System;
using agsXMPP;

namespace TestAgs
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            XmppClientConnection connection = new XmppClientConnection ();
            connection.OnLogin += delegate {
                Console.WriteLine ("logged in");
            };
            connection.Server = "gmail.com";
            connectio开发者_如何学编程n.ConnectServer = "talk.google.com";
            connection.Username = "my username"; // I tried both with and without '@gmail.com'
            connection.Password = "my password";
            connection.Open();
        }
    }
}

This compiles fine, but when I try to run it, nothing happens. It runs and completes without any errors, but "logged in" never gets printed to the console. What am I doing wrong?

If it makes a difference, I'm using Mono 2.4 on Ubuntu 10.04.


Unless connection.Open () blocks, which I doubt, the issue is that your program hits the end of main, and therefore it is done running and ends.

How you want to keep it from exiting depends on what you are trying to do, but one way would be a ManualResetEvent:

var mre = new System.Threading.ManualResetEvent (false);
mre.WaitOne ();

Of course, now you may have the opposite problem, there is no way for your app to finish.


I think issue is port number. You did not supply 5222 or 5223 in the connection.


just add Console.ReadLine(); after the line 'connection.Open();'


// connection.Server = "gmail.com";
connection.ConnectServer = "talk3.l.google.com"; OR
connection.ConnectServer = "talk2.l.google.com";
connection.Username = "my username"; // I tried both with and without '@gmail.com'
connection.Password = "my password";
connection.Open();

talk3.l.google worked fine for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜