Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Rohith #1
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Subject: Connecting to Gtalk
I am a new user of this agsxmpp library. I am using .NET framewok 1.1.
Can you let me know how do i develop a client with which i can chat with other Gtalk users.
(Something like an GTalk i have to develop an IM)
What are all the libraries needed or what extra serviers i have to run.
I currently have the library alone. If possible can you give me a sample code which works.
Avatar
Jabberer #2
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Hello,

Please download our samples from the homepage. There is a complete chat client sample called MiniClient.
Also take a look at the following page:
http://www.ag-software.net/index.php?option=content&ta…
if you have an google account you dont have to run your server. But of course you can run your own public xmpp server if you want and talk to google users over your server. For .NET 1.1 you need only the agsXMPP library which includes the Mone.Security library for secure connections.
Software Developer
AG-Software
Avatar
Rohith #3
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
I have tried to use the sample code to connect with google account. But i am not sure whether i am connected with my google account.

Sample code that i have used.

xmpp = new XmppClientConnection();
                xmpp.Server = "gmail.com";
                xmpp.ConnectServer = "talk.google.com";
                xmpp.Username = "rohithc@gmail.com";
                xmpp.Password = "*****";
                xmpp.Port = 5222;
                xmpp.UseSSL = false;
                xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
                xmpp.OnError += new ErrorHandler(xmpp_OnError);
                xmpp.Status = "Online";
                xmpp.Priority = 5;
                xmpp.Open();
                xmpp.OnMessage += new agsXMPP.XmppClientConnection.MessageHandler(xmpp_OnMessage);
                xmpp.Show = agsXMPP.protocol.client.ShowType.chat;
                // Send message to user
                agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message("raja00cs@gmail.com", agsXMPP.protocol.client.MessageType.chat, "Test");
                xmpp.Send(msg);

I have only the agsxmpp library. I am not running any other servers or anything..as i am using google account. But when i run this code i get an exception.

Object reference not set to an instance of an object.
   at agsXMPP.net.ClientSocket.Send(Byte[] bData)
   at agsXMPP.net.ClientSocket.Send(String data)
   at agsXMPP.XmppConnection.Send(String xml)
   at agsXMPP.XmppConnection.Send(Element e)
   at TestGtalkClient.Form1.buConnect_Click(Object sender, EventArgs e) in d:\rohith\programs\testgtalkclient\form1.cs:line 108

where the line 108 is :    xmpp.Send(msg);

Kindly let me know what i am doing wrong.
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Hello,

you don't have to set the ConnectServer. You can set the AutoResolveConnectServer = true. Then the lib resolves Connect Server using SRV-Records. But this is no error. Both should work.

The Open Method is async. This means when Open returns you are not connected yet.

  • Catch the OnLogin Event to get notified when the login was successful
  • In the OnLogin mark yourself as online by sending your presence (SendMyPresence)
  • Now you can send you message

Study and try the MiniClient sample. Everything you need is covered there.
Software Developer
AG-Software
Avatar
Rohith #5
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Jabberer,

Thanks for your reply. But still i am not able to connect to the google account. The onLogin event is never fired. Also I downloaded the miniclient application and tested it. In the jabber id i gave my gmail account and password. then i clicked the + button and tried to add another google account to chat with. But When i cliked add button it gave me this exception

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at agsXMPP.net.ClientSocket.Send(Byte[] bData)
   at agsXMPP.net.ClientSocket.Send(String data)
   at agsXMPP.XmppConnection.Send(String xml)
   at agsXMPP.RosterManager.AddRosterItem(Jid jid, String nickname, String[] group)
   at agsXMPP.RosterManager.AddRosterItem(Jid jid, String nickname)
   at MiniClientVB.MiniClient.frmAddRoster.cmdAdd_Click(Object sender, EventArgs e) in D:\Rohith\ChatApplication\GMAILAPI\VS2003\MiniClientVB\frmAddRoster.vb:line 116
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Kindly let me know what problem is this.

Thanks
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Robith,

what did you enter as username and server?
I'm not sure if we updated the VS2003 MiniClient sample for Gmail. Check if it is using the AutoResolveConnectServer or ConnectServer property in the Login Form.
If you are not able to login please post your XML Debug.
Did you try the VS2005 MiniClient the binary or source version?

Alex
Avatar
Rohith #7
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Alex,

For Jabber id i gave rohithc@gmail.com and my password. Priority, Port and Resource I left as default. Also I didnt check any of the check box options. And then I clicked the Login button..At this point i am not sure whether i am logged in or not as it(Miniclient) does not give any notification for that. Then I clicked on the Add Contact option (+ button) and added a new contact. Gave email id as raja00cs@gmail.com and Raja as nick name. Then when i clicked Add button in that form, it gave the exception which i have posted above. Kindly let me know where the problem is .

Thanks
Avatar
Rohith #8
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Alex,

This is the XML debug string.

SEND: <iq xmlns="jabber:client" id="agsXMPP_1" type="set"><query xmlns="jabber:iq:roster"><item jid="raja00cs@gmail.com" name="Raja" /></query></iq>

Thanks
Avatar
Alex #9
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
This is only a small snippet of the debug Log.

I just tried it and had no problem to connect to GTalk with the VS2003 MiniClient sample.

just update the code in the OnClick event of the Login Button in the Login Form to the following:

  1. private void cmdLogin_Click(object sender, System.EventArgs e)
  2.         {
  3.             Jid jid = new Jid(txtJid.Text);
  4.            
  5.             _connection.Server                      = jid.Server;
  6.             _connection.Username                    = jid.User;
  7.             _connection.Password                    = txtPassword.Text;
  8.             _connection.Resource                    = txtResource.Text;
  9.             _connection.Priority                    = (int) numPriority.Value;
  10.             _connection.Port                        = int.Parse(txtPort.Text);
  11.             _connection.UseSSL                      = chkSSL.Checked;
  12.            
  13.             _connection.ConnectServer               = "talk.google.com";
  14.             //_connection.AutoResolveConnectServer  = true;
  15.            
  16.             _connection.UseCompression              = true;
  17.            
  18.  
  19.             _connection.RegisterAccount             = chkRegister.Checked;
  20.            
  21.             this.DialogResult = DialogResult.OK;
  22.            
  23.             SaveSettings();
  24.            
  25.             this.Close();
  26.         }

Alex
Avatar
Rohith #10
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Alex,

I have tested the MiniClient again by adding the code in cmdLogin_Click. But it still gives the same result (The exception i mention above). also the Log that is Present in DEbug tab is

SEND: <iq xmlns="jabber:client" id="agsXMPP_1" type="set"><query xmlns="jabber:iq:roster"><item jid="raja00cs@gmail.com" name="Raja" /></query></iq>

Only this info is present in the Debug tab. Kindly let me know whether this will be any firewall problem or I have to run any other servers. The resource textbox option i have left as MiniClient. Do i have to change this? Also Let me know whether this is connecting to the Gmail id (i.e in Jabber id) i am giving. As it does not provide any indication that it is logged in. If possible send me a sample Client project to connect only to Gmail id.(Without any server or other projects)

Thanks
Avatar
Jabberer #11
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Rohith,

you are doing smth wrong. I assume you click on the "+" icon to connect. Which is wrong. Go to the main menu File -> Connect. Then the Login form will show up. Enter there you jabber id which is be smth like test@gmail.com. In the Password field enter you pasword and click on the Login Button.
After that there must be more in the Debug Log.

Jabberer
Software Developer
AG-Software
Avatar
Rohith #12
Member since Feb 2006 · 7 posts · Location: Chennai
Group memberships: Members
Show profile · Link to this post
Jabberer/Alex,

Actually this is a firewall Problem. Now i got it working. Thanks for your replies.

Thanks
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