Oct 28
Writing a gTalk (Jabber/XMPP) client in Java
From its Wikipedia entry, “Extensible Messaging and Presence Protocol (XMPP) is an open, XML-inspired protocol for near-real-time, extensible instant messaging (IM) and presence information (a.k.a. buddy lists). It is the core protocol of the Jabber Instant Messaging and Presence technology. The protocol is built to be extensible and other features such as Voice over IP and file transfer signaling have been added.”
There are a large number of XMPP server and client implementations and code libraries. We will use the Smack open source Java library to implement a simple client that can connect to any Jabber service. Google’s messaging service uses the same protocol and we will use it for the example.
Create a folder for your project. Create a “lib” subfolder.
Download the Smack library and extract the following files to the lib folder:
- smack.jar
- smackx.jar (for the extensions)
- smackx-debug.jar (for the enhanced debugger)
Debugger screenshots: 1 | 2 | 3 | 4
As of this writing, the Smack API is in version 3.0.4 (build date: June 12, 2006). Create ChatClient.java and use the code snippets below for the methods of this class. You can also download the project files from the link at the end of this post.
The code below shows how to connect to the gTalk service:
1 2 3 4 5 6 7 8 9 10 | // import org.jivesoftware.smack.ConnectionConfiguration; // import org.jivesoftware.smack.XMPPConnection; ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com"); connection = new XMPPConnection(config); connection.connect(); connection.login(your_username, your_password); |
“talk.google.com” is the host. 5222 is the port number and “gmail.com” is the service name. Although they are different here but usually, the service name is same as the hostname. Let us now get hold of the buddy list:
1 2 3 4 5 6 7 8 9 10 11 | // import org.jivesoftware.smack.Roster; // import org.jivesoftware.smack.RosterEntry; Roster roster = connection.getRoster(); Collection<RosterEntry> entries = roster.getEntries(); System.out.println("\n\n" + entries.size() + " buddy(ies):"); for(RosterEntry r:entries) { System.out.println(r.getUser()); } |
We can also send a message to a buddy by using the Chat class:
1 2 3 4 | //import org.jivesoftware.smack.Chat; Chat chat = connection.getChatManager().createChat(to, this); chat.sendMessage(message); |
The first argument is quite obvious. The second argument is an instance of a class that implements the org.jivesoftware.smack.MessageListener interface. This listener receives incoming chat messages and calls the interface method
1 | public void processMessage(Chat chat, Message message) |
to process the message. We can now disconnect from the messenger service:
1 | connection.disconnect(); |
Thus, we have a bare-bones Jabber client. The complete program looks like this. You can download the project (see update below) with instructions on compiling and running it. It has a hard-coded username and password which will have to be changed. You will also need to enter the email address of your gTalk buddy before sending any message. The person you are trying to communicate with should already be in your buddy list.
Update (10 July 2009):
Check this out for SASL authentication errors: http://server.everfine.com.tw/blog/archives/2009/06/smack-api.html
Update (30 December 2009):
I no longer have a copy of the original project archive that I posted.
However, a modified version is available here: http://groups.google.com/group/jujuyjug/files?pli=1

February 18th, 2008 at 4:21 pm
Hi Abhijeet
I got the following error while running this program.
In fact, I am getting this error from some other implementation also. Where could it went wrong?
Exception in thread “main” Could not connect to talk.google.com:5222.: remote-server-timeout(504) Could not connect to talk.google.com:5222.
— caused by: java.net.UnknownHostException: talk.google.com
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:823)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)
at ChatClient1.login(ChatClient1.java:25)
at ChatClient1.main(ChatClient1.java:71)
Nested Exception:
java.net.UnknownHostException: talk.google.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:815)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)
at ChatClient1.login(ChatClient1.java:25)
at ChatClient1.main(ChatClient1.java:71)
February 21st, 2008 at 12:11 am
Hi Chaitanya,
Even though it doesn’t seem to be a problem with the program, I ran it again and was able to chat just fine.
Problem seems to be with your internet connectivity. Are you able to ping talk.google.com?
February 23rd, 2008 at 10:29 pm
Chaitanya (via mail):
=============
Hi Abhi
I am not able to resolve it.
I am not able to connect to talk.google.com through my program.
One reason could be I m trying from office as I don’t have net connection as of now at home.
Still have to try.
If you know the reason please let me know.
Thank you,
Chaitanya
February 23rd, 2008 at 10:34 pm
Can you ping talk.google.com from the command line?
You are trying from office … then it could also be a proxy server issue.
If you are using IE, go to Tools >> Internet Options >> Connections >> LAN Settings. See if there is a proxy server specified there. If not, there might be an automatic configuration script specified. Take a look at that script and see if you can figure out the proxy server being used.
Also, check that talk.google.com is not blocked from your office. Some companies have their internal messaging solutions and block others.
February 25th, 2008 at 3:35 pm
Hi Abhi
talk.google.com is accessible. It is not blocked yet
) from my office.( Infosys- bangalore)
It is some proxy server issue. I will explore and let u know.
Unfortunately, getting Net at my home is getting delayed to try these kinda things.
Thank you,
Chaitanya
April 28th, 2008 at 11:01 pm
[...] if you guys have all the necessary info itll go smoother.. Trying to load the sample from … Abhijeet Maharana » Writing a gTalk (Jabber/XMPP) client in Java getting the following errors… generics are not supported in -source 1.3 (try -source 1.5 to [...]
April 28th, 2008 at 11:15 pm
Hello, im trying to test this on a BlackBerry handheld. Have you any experience with J2ME or the
BlackBerry JDE 4.3.0(BB JDE) ? I have posted the 2 errors im recieving from the BB JDE to the
BlackBerry Forums.. http://www.blackberryforums.com/developer-forum/127332-smack-api-need-help-w-sample-chatclient.html
April 29th, 2008 at 12:04 am
Hi James,
My *pure guess* below since I have no experience with Blackberry.
Options:
1. Try passing “-source 1.5″ parameter. You will need to look up the documentation for rapc.exe to figure out how to do that.
2. Don’t use generics and for-each loop.
Above code is not tested. You may need to fix minor issues.
Do let me know if this fixes your issue.
April 29th, 2008 at 9:54 pm
Thanks, Ill check that out today.
What are generics? and how do i addin the smack api libraries? I understand you dont have any experience
with the BlackBerry JDE but, how would one addin the smack api using another IDE? I tried copying the .jar’s
to the /bin folder to no avail. Thanks for your assistance.
If you curious, I can assist you in loading the BlackBerry JDE and also a BlackBerry simulator handheld and
you would be on your way to developing apps for blackberry. I have many many samples.. then, hopefully
you could take me under your wing. I could use a mentor.
April 29th, 2008 at 10:43 pm
Generics enable compile-time type checking for collections making them safer to use. http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
Most IDEs have something under project properties to add jars to the class path. Eclipse has a “build path” feature and once you add your jar here, it is passed to the compiler and runtime when the project is launched.
Many thanks for the generous offer. I could definitely use some help if and when I start exploring blackberry development. I think I should start using a blackberry now! And I would rather have it the other way round: you as my mentor! If you use twitter, I am available at http://twitter.com/maharana
Regards.
April 30th, 2008 at 9:07 pm
Consider this.. I have nearly zero experience with Java. I can get you up to speed with the BlackBerry
JDE and then ill have to hand over the mentorship.
April 30th, 2008 at 10:18 pm
I will give you the links for getting started with BlackBerry Dev using the BlackBerry JDE 4.3.0
Download BlackBerry JDE 4.3.0 from http://na.blackberry.com/eng/developers/downloads/jde.jsp
Download simulators and the BlackBerry Email and MDS Services Simulator Package 4.1.4,
I use the 4.2.2 versions of the simulator. I prefer the 8300 series BlackBerry handhelds,
http://na.blackberry.com/eng/developers/downloads/simulators.jsp
once all this is loaded then make sure you have C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin
in your path. Once you are this far we can continue with the training.
April 30th, 2008 at 10:24 pm
BTW I found an option to import .JAR files into a project. That must be it..
April 30th, 2008 at 11:58 pm
I did try to download the Eclipse plugin. 200+ MB with a weird download method. I couldn’t use a download manager and it broke mid way
Will try again tonight. Or go with the smaller JDE download. Good that you found that option. Let me know if you are able to get the chat client working.
May 2nd, 2008 at 9:21 am
I just use the BB JDE. I made the changes you suggested and im still getting exceptions, in strange places..
Like ‘missing symbol’ on collections.. ect. ill post some output later..
May 2nd, 2008 at 10:25 am
here is the code..
May 2nd, 2008 at 10:26 am
here is the output..
May 2nd, 2008 at 9:57 pm
Can’t really be of any help here. Most likely, the runtime is different with a different API. But, I am merely *guessing* here. The blackberry forum will be a better place as you will get some definitive answers there.
Regards,
Abhijeet.
May 8th, 2008 at 4:49 pm
Can I Transfer file using this library ?
May 8th, 2008 at 8:23 pm
Hi,
I did a quick search of the igniterealtime forums and came across this: http://www.igniterealtime.org/community/message/118501#118501
June 10th, 2008 at 9:16 am
[...] There are also Java based libraries that can be used for the custom Java client development such as http://abhijeetmaharana.com/blog/2007/10/28/writing-a-gtalk-jabberxmpp-client/ [...]
June 13th, 2008 at 7:51 pm
I read similar article also named a gTalk (Jabber/XMPP) client in Java | Abhijeet Maharana, and it was completely different. Personally, I agree with you more, because this article makes a little bit more sense for me
August 2nd, 2008 at 9:17 am
I am behind a proxy server. How can I use smack API to connect to gtalk ?
August 3rd, 2008 at 12:49 am
This should help: http://beerholder.blogspot.com/2008/07/tunneling-eclipse-communication.html
I haven’t tried doing it though. Don’t have a Ubuntu installation nearby. Do let me know how it works out.
August 5th, 2008 at 2:54 pm
is there is mistakes in my settings
please guide me properly
eagerly waitng for reply
August 5th, 2008 at 2:59 pm
one more it gives me error if i set class path as you mention in readme.txt in gtalkClient project
August 5th, 2008 at 5:49 pm
where should i enter my buddies name?
August 5th, 2008 at 8:18 pm
Hi, thanks for dropping by!
This is not a web application. So you don’t need Tomcat. Just compile and run it from the command line. The readme file has commands for windows. On Unix, replace ; with : and \ with /.
I have put comments where you need to provide your login information and your buddy’s gmail id. Look at the main method of ChatClient.java.
Hope this helps.
PS: This is just a command line sample to get you started. There is no fancy UI.
August 6th, 2008 at 9:50 am
very good maorning
really thanks Abhijeet for response
this is really helpful for me
please tell me about setting of classpath
in linux classpath is set in /root/.bash_profile and .bashrc
tell me as early as possible
thanks.
August 6th, 2008 at 10:57 am
i set path as in /root
.bash_profile
export CLASS_PATH=/usr/local/gtalkClient/lib/smack.jar:/usr/local/gtalkClient/lib/smackx.jar:/usr/local/gtalkClient/lib/smackx-debug.jar
heyyyyyyyyy
and its working properly
one window is open showing status.
but i am not getting meaning of IQ and how can i send message. please send me
thanks
August 6th, 2008 at 11:00 am
my out put is like
23 buddy(ies):
EDIT (abhijeet): I have removed your contacts’ addresses from here
—–
Enter your message in the console.
All messages will be sent to abhijeet.maharana
—–
Exception in thread “Smack Packet Reader (0)” java.lang.ExceptionInInitializerEr ror
at org.jivesoftware.smackx.provider.DelayInformationProvider.parseExtens ion(DelayInformationProvider.java:51)
at org.jivesoftware.smack.util.PacketParserUtils.parsePacketExtension(Pa cketParserUtils.java:378)
at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketPars erUtils.java:107)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:27 2)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)
Caused by: java.lang.NullPointerException
at java.util.TimeZone.parseCustomTimeZone(TimeZone.java:780)
at java.util.TimeZone.getTimeZone(TimeZone.java:484)
at java.util.TimeZone.getTimeZone(TimeZone.java:478)
at org.jivesoftware.smackx.packet.DelayInformation.(DelayInforma tion.java:51)
… 6 more
August 6th, 2008 at 11:31 am
what about chat window??????????????
August 6th, 2008 at 4:30 pm
please reply
August 6th, 2008 at 8:26 pm
1. As I have already mentioned in the post and in the comment above, this is a command line *only* sample. The window that opens is for debugging. You can’t enter chat messages there. Chat messages have to be entered in the console where you run the program.
2. See the screenshot at http://abhijeetmaharana.com/blog/bloguploads/gtalkclient/gtalkclient.JPG. A test user is chatting with abhijeet.maharana from the command prompt on the left.
3. I am using Windows and I am not getting the exception you have reported above. Mail me your program. Remove your password but keep everything else intact. Ill try to run it and see if I can reproduce the above exception.
August 11th, 2008 at 8:39 pm
Hi Abhi,
Is it Possible to Capture GTalk Conservation and Synchronizing with Outlook. Pl let me Know
August 11th, 2008 at 8:41 pm
Hi Abhi,
Is Jabber can be Customised to use GTalk and Synchronizing Chat Conservations to Oulook
August 11th, 2008 at 9:39 pm
Hi Manoj, thanx for dropping by.
For the first part, this should help: http://blogoscoped.com/archive/2006-05-02-n79.html
I didn’t get what you mean by “Synchronizing Chat Conservations to Oulook” ???
August 30th, 2008 at 12:54 pm
Hi abhi
once again i start work on gtalk ………….
i am successful to run it on linux redhat but not able to succeful to display all chtting on terminal(command promt)(debug shows me availability of my friend and all chat messages).sometimes some chats not display on prompt .If you have any idea please guide me.
August 31st, 2008 at 6:22 pm
Hello Sweety, I am afraid I won’t be able to spend time on the issue you have mentioned. Apologies. However, I would strongly recommend that you join the IgniteRealtime forums. I am sure you will get a few answers there. http://www.igniterealtime.org/community/index.jspa
Regards,
Abhijeet.
September 2nd, 2008 at 10:20 pm
Hi Abhijeet,
I am trying to use connect the GTalk using the method and the process as mentioned by you above but I am getting the following Error
09-02 22:09:38.984: INFO/XMPP Error(3926): Could not connect to talk.google.com:5222.: remote-server-timeout(504) Could not connect to talk.google.com:5222.
September 3rd, 2008 at 12:14 am
Are you able to ping the server directly? Or maybe you are behind a proxy? http://beerholder.blogspot.com/2008/07/tunneling-eclipse-communication.html
September 5th, 2008 at 2:29 pm
Hi Abhijeet,
i am able to sucessfully run it as described you but when I tried to run on the Android platform by importing the smack jar it is giving me this error
09-05 14:24:54.964: WARN/System.err(2403): Could not connect to talk.google.com:5222.: remote-server-timeout(504) Could not connect to talk.google.com:5222.
09-05 14:24:54.974: WARN/System.err(2403): — caused by: java.net.UnknownHostException: talk.google.com – talk.google.com
09-05 14:24:54.994: WARN/System.err(2403): at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:823)
09-05 14:24:54.994: WARN/System.err(2403): at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)
Does I have modify the smack jar? If yes please tell me how.
September 5th, 2008 at 9:05 pm
Deepak, I do not have any experience with Android yet. Can’t be of any help here!
EDIT: This should help.
From a quick Google search: http://davanum.wordpress.com/2007/12/31/android-just-use-smack-api-for-xmpp/
September 6th, 2008 at 9:24 am
I am trying to figure out how you in the screenshot you got it to stream incoming messages to the commandline. As near as I can tell is your sample you never actually call processMessage() which dumps incoming messages to the screen as your jpg shows. Can you clarify?
September 7th, 2008 at 11:54 pm
Hi Anthony, thanks for dropping by!
processMessage() belongs to the MessageListener interface. An instance of a class implementing this interface is registered with the Chat instance created for a buddy using createChat(). It is then the Chat instance’s responsibility to invoke processMessage() when a message is received from the buddy. See this.
In the example above, sendMessage() does this for us. 2nd parameter is ‘this’ because our main class itself implements MessageListener.
Chat chat = connection.getChatManager().createChat(to, this);
Actually, since we are sending all messages to the same buddy, we can move this line outside sendMessage(). Hope this answers your question.
October 24th, 2008 at 4:02 pm
My school closed most of the ports including 5222.
Can I use smack API to chat with gmail users?
October 24th, 2008 at 11:11 pm
meebo.com? In case its blocked as well, you can use proxies [which you know are good] to access it.
As for your other question, I’m not sure at the moment. Will have to read up and try out things to be able to answer it.
October 30th, 2008 at 6:25 pm
is there a c/ c++ version of this tutorial please?
any c/ c++ libraries that are similar to smack?
October 31st, 2008 at 12:12 am
Hi,
This is the only version of this tutorial at the moment.
For a C version, you can try the Loudmouth project http://www.loudmouth-project.org/about.
November 11th, 2008 at 9:59 pm
Hi Abhijeet,
Thanks for providing the code in your blog. it gives the good understanding of basics.
I am facing a strange issue !!
On running the code in my machine, I am able to chat with my userID as both sender and receiver (in console, as just echo program). However, while chatting with another gmailID, My msgs are reaching the reveiver to thier gtalk, but thier replys are not displayed in my console.
I can see the reply packets are received in the degugger window, but processMessage() of MessageListener is not getting invoked in this case.
The same problem occurs, even with my local Openfire installed in my machine.
Please provide me some insight on this issue.
Thanks,
Mari
December 5th, 2008 at 12:11 am
Hi Mari,
Did you miss out the registration of MessageListener?
December 14th, 2008 at 12:56 am
Your appication works really well.i used Netbeans IDE and it worked perfectly.Do you have gtalk voice capable java application buddy? may i know the link to download the source code of that programme…
December 14th, 2008 at 1:06 am
your application worked really fine. i used it with Netbeans IDE and it was really cool. Do you have gtalk voice capable smack sample like this one?
December 14th, 2008 at 5:15 am
Hi im again…
Seems your given project need some changes to work with Smack 3.1.0.
DO you have that updated project? Please give me a help as im a newbie to Programming.
i tested many times your application and found Messages sends to other client perfectly. but when i receive some msgs from the client, it some times failed to display the received msg at the command line.any explanation about this case??
December 14th, 2008 at 10:37 am
Hi Sadun, I havent been able to work on this any further. Havent tested with 3.1.0. So can’t be sure what the issue is. Do let me know if you manage to isolate the issue. Looks like Mari’s issue was related.
December 16th, 2008 at 11:45 pm
Thanks for replying.. anyway how do i use google talk voice functionality using smack and Java SE platform?? i wanna use gtalk’s voice for my project on java.pls help me if you know those stuffs.if you have a project which used google talk voice pls send it to me on sandun1234u@gmail.com
December 17th, 2008 at 2:26 am
Hi Sandun, I wish I could help. But I haven’t had a chance to work more with Smack. I would suggest that you try out the forums.
December 23rd, 2008 at 10:43 am
on my server java 1.3 is installed, and I need smack and other jar files with java 1.3 … can you help me in this scenario?
December 23rd, 2008 at 7:39 pm
Hi Aruna,
I haven’t looked but igniterealtime should have a download archive somewhere that could contain the earlier releases.
January 2nd, 2009 at 7:35 pm
Hi, Your article was very informative.
I was trying to accomplish a File Transfer using the smack extensions provided by the library. I used the example contained in the doc, but that doesn’t seem to be working properly. On the sender side, my program prints out the msg that File transfer started, When I use the debugging interface for the second app (i.e the one to which i am sending a file to), no event is received.
Also, in the first app, the enhanced debugger spits out the foll error
“IQ type not understood”
I examined the packets send by the first app, it shows that the first type of packet in the File Transfer is of type IQ=set
Any help would be much appreciated..
Thank you for your time.
Cheers,
Earlence Fernandes
January 3rd, 2009 at 9:07 pm
Hi Earlence. I didn’t have a chance to work more on this. I am afraid I can’t be of any help here. You could try the Ignite Realtime forums.
March 4th, 2009 at 6:54 pm
hi dude
Can u help me creating a XMPP Client for monile in j2me???
March 4th, 2009 at 10:46 pm
Hi Abhijeet,
I tried your code snippet, but unfortunately it gives he XMPP connect error.
XMPPError connecting to talk.google.com:5222.: remote-server-error(502) XMPPError connecting to talk.google.com:5222.
Although I am trying this from my office PC, yet I have got direct connection to the internet and no proxy involved. I am using Linux RHEL 4 along with Java 5.
I have also tried a gtalk-eclipse plugin, and got the same error there.
Can you please help.
March 4th, 2009 at 10:50 pm
Hi Abhijeet,
The whole stack trace is:
XMPPError connecting to talk.google.com:5222.: remote-server-error(502) XMPPError connecting to talk.google.com:5222.
— caused by: java.net.ConnectException: Connection timed out
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:900)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at com.jeet.test.SampleGTalkUtil.login(SampleGTalkUtil.java:23)
at com.jeet.test.SampleGTalkUtil.main(SampleGTalkUtil.java:62)
Nested Exception:
java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at org.jivesoftware.smack.proxy.DirectSocketFactory.createSocket(DirectSocketFactory.java:28)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:888)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at com.jeet.test.SampleGTalkUtil.login(SampleGTalkUtil.java:23)
at com.jeet.test.SampleGTalkUtil.main(SampleGTalkUtil.java:62)
March 5th, 2009 at 8:15 am
@Prosenjeet @Peetamber
Unfortunately I have been out of touch with this for quite sometime and caught up with other things at the moment. I am afraid I can’t be of much help here. Do try the forums though.
March 10th, 2009 at 12:01 pm
Hi,
Can we connect to other messengers(yahoo, MSN, AOL and etc..) using smack API? if yes can you provide me useful resources.
Thanks
Sri
March 14th, 2009 at 1:28 pm
I executed this code and I got Authentication failed… What would be the reason? I used my gmail account username and password
May 14th, 2009 at 4:54 pm
I tried writing the program from scratch I am getting this exception.Please help me figure it out.
Exception in thread “main” SASL authentication failed using mechanism PLAIN:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentica
tion.java:325)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
at test.main(test.java:11)
May 20th, 2009 at 4:58 pm
Hi Ananth,
You need to specify full username including ‘gmail.com’ at the end,then you can avoid that error.
May 21st, 2009 at 3:42 am
Hi Sandeep,
I use the full username (with the correct password) and I keep getting the same exception ananth has.
SASL authentication failed using mechanism PLAIN: … (etc)
May 26th, 2009 at 1:54 am
James,
For GTalk connections, I seem to be required to add the @gmail.com to the username, like so
// provide your login information here
c.login(“madnesstestuser@GMAIL.COM”, “password”);
best luck,
hamy
May 29th, 2009 at 8:23 am
Hello,
I tried all three ways
1. c.login(“sprateek007″, “password”);
2. c.login(“sprateek007@gmail.com”, “password”);
3. c.login(“sprateek007@GMAIL.COM”, “password”);
But I am getting the same error
Exception in thread “main” SASL authentication failed:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:209)
………
Please tell me the possible solution for this problem.
June 1st, 2009 at 8:51 am
Hello Abhijeet,
Can we use this Java API to update the user status/status message or for sending friend request etc. Please tell me how we can do all these stuff.
Regards,
Prateek
June 1st, 2009 at 9:17 am
Hi Prateek, take a look at http://www.adarshr.com/papers/xmpp2. Its packed with information!
June 15th, 2009 at 7:04 pm
Hi Abhijeet,
I want to make same program in .NET. Cau u please help me for the same?
How can I get libraries for .NET?
Thanks and Regards
Jai
June 16th, 2009 at 10:05 pm
hi Abhijeet,
i worked with this example. it really worked fine for me. i have someclarifications to made. how can i get the availability status of the user i used like this.
Presence presence = roster.getPresence(“abdul2782@jabber.org”);
if (presence.getType() == Presence.Type.AVAILABLE) {
// do something
}.
but it doesn’t worked for me. also i tried to take status like
presence.getStatus();but it shows always null for all the users even though the user is online.
Also one more thing how can i get chat history
July 6th, 2009 at 12:38 am
I try this example but does’t work, i can’t see “Is avaible”, help me …. , thanks !
ConnectionConfiguration config = new ConnectionConfiguration(“talk.google.com”, 5222, “gmail.com”);
XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login(“userName@gmail.com”, “password”);
return connection;
Roster rosterr = connection.getRoster(); //contacts
Presence presence1 = rosterr.getPresence(“My friend of cantact@gmail.com“);
System.out.println(presence1.getMode());
July 13th, 2009 at 7:52 pm
Thank u very much its working nicely………
Thanks for sharing such a useful code.
July 27th, 2009 at 6:00 pm
Thanks Abhijeet,i was looking for same code which you have provided.Wonderfull job.Now i can create a google bot .
August 19th, 2009 at 6:12 am
Hi!
How can i extract the raw xml packet?
(packet.toXML method hides most part of server reply)
Now I’m working on gmail notification.In debugger window(raw received packets)I can see
the “result” packet.
output of packet.toXML :
in Raw Received Packets : <mail-thread-info tid=”13
….
….
Help Me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
October 1st, 2009 at 3:11 pm
hi abhijeet i tried out your code…..it works fine when used with console …..but when i tried it out along with a chat window …..the XMPP Debugger window appears partially and the program hangs up ….please help me to sort out this problem
October 2nd, 2009 at 10:39 am
how to set proxy server ,in Netbeans while using this API.
i got exception
Exception in thread “main” Could not connect to talk.google.com:5222.: remote-server-timeout(504) Could not connect to talk.google.com:5222.
— caused by: java.net.UnknownHostException: talk.google.com
October 3rd, 2009 at 12:18 pm
swarnabh… a random stray thought from the top of my head … I think the UI thread is being locked up somewhere. Check that out and create threads as needed.
October 7th, 2009 at 12:46 pm
i tried your example its worked partially fine for me.i can send chat with this but unable to receive proprlly.some time its show null then msg received it shows.but most of tyhe time it doesent receive any msg or if it received its not displaying ?please help
October 18th, 2009 at 10:46 am
Hi,
I have developed a nearly full-functionality Universal Chat Client which lets one connect to an arbitrary server, and service.I want to get it distributed to everyone whoever may be interested to develop further on it. You can find my profile:
http://www.ibm.com/developerworks/spaces/JavaCommBio
October 25th, 2009 at 8:16 am
Downloading now. Great work! Thanks!
November 2nd, 2009 at 12:33 pm
Sorry, I’m trying to download your project with instructions on compiling and running, but the download link isn’t available any more.
Is there a way you could send me that project? Or upload it again somewhere?
November 6th, 2009 at 12:18 am
Hi Marijo,
Thanks for pointing that out. Unfortunately, I didn’t have a copy of the zip I had uploaded to GeoCities. So I googled around to see if the zip is available somewhere and sure enough!
http://groups.google.com/group/jujuyjug/files?pli=1
But I don’t remember if I had posted a NetBeans project. The search also led me to a couple of other blogs with a strikingly similar post
November 26th, 2009 at 1:16 am
Hi Abhijeet,
I have downloaded your project and run it successfully. But when I run it, a GUI gets opened. Is there anyway in which I can just implement this messenger in text mode only. Like during the execution of binary, I need to enter the message on standard input console, instead of entering the same in GUI.
I need to develop a sms chat solution, in which my application will receive SMS from user and will send the same to his friend on gtalk. so for this my need is to have a gtalk messenger client without GUI.
Thanks in advance for your help.
BR,
Kartik
November 27th, 2009 at 8:10 am
I have already linked to the single-file text mode program in the post itself.
http://abhijeetmaharana.com/blog/bloguploads/gtalkclient/ChatClient.java.txt
November 28th, 2009 at 5:32 pm
Hi Abhijeet,
Thasnk for your work. I am using Smack library for communication between two of my server machines. One Server is Google App Engine(Will call it GAE) server and another is my mocal machine.
I send a message from my local machine to GAE and it reaches there and then server respond it by saying ok i received it and processed it. Then client machine receive this message.
Now the problem is that almost 30-40% messages are not being received my Client machine which is using smack library. I check the server logs and it always send messages without error.I tried to send the same message with Gtalk and i always receieve response in Gtalk Chat window, but with smack library i keep loosing my response messages.
DO you know what is wrong here.
December 8th, 2009 at 11:35 am
Hi Abhijeet
I am sending message to my friend from my client program.My friend can get message, but message is not displayed in gtalk window for me.Please help me,
December 29th, 2009 at 6:48 pm
Hi abhijeet,
your ‘download the project’ link is invalid. And also i am able to send message to a buddy but when he replies the listener is unable to listen, is there any common mistake i am doing.
thanks for your time,
chaitu
December 30th, 2009 at 5:20 pm
Thanks for pointing out. I have updated the post. Try running from the new link.
January 16th, 2010 at 2:38 pm
hii abhijeet, thanks 4 your project,
As we r running your code in the IBM websphere server,we couldnt retrive the messages (because of two jvm running at the same time).
Please give us solution for this error.
January 28th, 2010 at 10:52 am
How can i create send Receive iq packets using smack api
January 28th, 2010 at 10:56 am
How can i create, send and Receive iq packets using smack api
i am already connected to xmpp server? is any error in packet format can u give me source code?
i tried everywhere from ignite to jabber.org but not got answer !!
folowing is packer format
final IQ iq1 = new IQ() {
public String getChildElementXML() {
return “”;
}
};
February 5th, 2010 at 7:38 am
hey
# Abhijeet Maharan
i really impressed by ur idea ……….
i haven’t tried this but seems great .
im trying to implement gtalk in web browser for my final year project will ur program will help me for gtalk in screenshot i saw call option will it help…….
please i want directly contact u please send me ur contact details asdfg3551.u@gmail.com….please reply soon