[jdev] Smack API and jabber.org

jlist9 at gmail.com jlist9 at gmail.com
Thu Jan 8 22:38:59 CST 2009


Thanks sumedha. It looks like you are not using the latest version
of Smack (3.1.0 beta), since the XMPPConnection class of this version
doesn't have a login(String, String, String, boolean) function.
It's login(String, String, String) instead.

But if it works, I wonder if it's possible for me to get the jar files
from you? I'd like to give that version a try.

Thursday, January 8, 2009, 6:42:27 PM, you wrote:

> Hi,
> I have following code block & it works.
> /sumedha

> xmppConnection = new
> XMPPConnection(serverCredentials.getServerUrl());
> try {
> 	xmppConnection.connect();
> } catch (XMPPException e) {
>       log.error("Failed to connect to server
> :"+serverCredentials.getServerUrl(), e);
> }
> //Pause for a small time before trying to login.
> //This prevents random ssl exception from Smack API
> try {
> 	Thread.sleep(100);
> } catch (InterruptedException e5) {
> 	log.debug("Sleep interrupted ",e5);
> }

> if(xmppConnection.isConnected()){
> 	if(! xmppConnection.isAuthenticated()){
> 	try {
> 		xmppConnection.login(serverCredentials.getAccountName()+"@"+
> 					serverCredentials.getServerUrl(),
> 					serverCredentials.getPassword(),
> 					serverCredentials.getResource(),
> 					true);
> 	} catch (XMPPException e) {
> 		try {
> 			log.error("Login failed for "
> 					+serverCredentials.getAccountName()
> 					+"@"+serverCredentials.getServerUrl()
> 					+".Retrying in 2 secs",e);
> 			Thread.sleep(2000);
> 			xmppConnection.login(serverCredentials.getAccountName()+"@"+
> 					serverCredentials.getServerUrl(),
>     				        serverCredentials.getPassword(),
> 					serverCredentials.getResource(),
> 					true);
> 			} catch (InterruptedException e1) {
> 				log.error("Sleep interrupted.",e1);
> 			} catch (XMPPException e2) {
> 				log.error("Login failed for :
> "+serverCredentials.getAccountName()
> 						+"@"+serverCredentials.getServerUrl(),e2);
> 				throw new AxisFault("Login failed for :
> "+serverCredentials.getAccountName()
> 						+"@"+serverCredentials.getServerUrl());
> 			}
> 		}
> 	        //Listen for Message type packets from specified server url
> 		//packetFilter = new AndFilter(new PacketTypeFilter(Message.class),
> 		//		new FromContainsFilter(serverCredentials.getServerUrl()));
> 		packetFilter = new
> FromContainsFilter(serverCredentials.getServerUrl());					
> 	}
> }					





> On Fri, Jan 9, 2009 at 3:00 AM,  <jlist9 at gmail.com> wrote:
>> Hello all,
>>
>> Has anyone tried using jivesoftware's Smack API to access
>> jabber.org? I tried some sample code on their forum but I was
>> getting an error. The same code (with the slight difference of
>> using a full email address) works fine for talk.google.com.
>>
>> Or, has anyone tried any java XMPP library with success?
>>
>>
>> The error:
>>
>> SASL authentication failed using mechanism PLAIN:
>>        at
>> org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:325)
>>        at
>> org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:395)
>>        at com.gn.xmpp.XmppTest.main(XmppTest.java:40)
>>
>> The sample code:
>>
>> ConnectionConfiguration cc = new
>> ConnectionConfiguration("jabber.org", 5222, "jabber.org");
>> XMPPConnection connection = new XMPPConnection(cc);
>> try {
>>     connection.connect();
>>     SASLAuthentication.supportSASLMechanism("PLAIN", 0);
>>     connection.login("your.jabber", "password", "resource");
>>     System.out.println(connection.isAuthenticated());
>> } catch (XMPPException e1) {
>>     e1.printStackTrace();
>> }





More information about the JDev mailing list