Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
azdragon2 #1
Member since Sep 2009 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Immediate Disconnect
Sorry to bother you Alex, but I have one more question. So I got everything set up once I fixed that error earlier.

Basically here's my problem: right after the connection is open, it immediately disconnects.

I can tell its disconnected because I traced through all the functions printing output:

Updating Google Talk Presence:
Calling INITSocket
Socket: ClientSocket
Calling _Open
Opening Socket
Calling SocketConnect sp
Calling SocketConnect
Calling DoChangeXmppConnectionState: Connecting
Connecting...
Calling DoChangeXmppConnectionState: Connected
Calling DoChangeXmppConnectionState: Disconnected

So the state in DoChangeXmppConnectionState is disconnected when I haven't called the Close yet. Here's my code:
public static void updatePresence(MyUserSettings mySettings, string presence)
{
            Console.WriteLine("Updating Google Talk Presence:");
            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = "gmail.com";
            xmpp.ConnectServer = "talk.google.com";
            xmpp.Port = 5222;
           
            xmpp.Open(mySettings.GTalk_Username, mySettings.GTalk_Password, "private_resource_name", 10);
           
            //Console.WriteLine("Updating Presence:");
            //xmpp.Status = presence;
            //xmpp.OnLogin += delegate(object o) { Console.WriteLine("Logged in"); xmpp.SendMyPresence(); xmpp.Close();};
}

Do you know why it's immediately disconnecting? Is it because of a login failure perhaps? or is my setup config incorrect?
Avatar
Alex #2
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have declared XmppClientConnection as local object in your function. The Open method is async and leaves your function immediately and your connection gets destroyed. Declare XmppClientConnection global.
Please study our examples, there is all you need,
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS