AnsweredAssumed Answered

Using smack with google hangout ?

Question asked by Nicolas on Jul 4, 2016
Latest reply on Jul 5, 2016 by Nicolas

Hello,

 

I'm trying to build a java application that sends messages through Hangout.

I've looked at smack which seems to answer to my problem, but the initial setup is kind of tricky, there's a lot dependencies and the behavior change when I add some libs.

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() //           .setUsernameAndPassword("<username>", "<password>") //           .setServiceName("gmail.com") //           .setHost("xmpp.l.google.com") //           .setPort(5222) //           .setHostnameVerifier(new HostnameVerifier() {                @Override                public boolean verify(String hostname, SSLSession session) {                     return true;                }           }) //           .build();  AbstractXMPPConnection connection = new XMPPTCPConnection(config); connection.connect();

 

With only smack-core and smack-tcp, the application manage to connect (at least no error is shown).

When I add smack-extension, for sending a message, the above code fail with this strange error:

Exception in thread "main" java.lang.NullPointerException      at org.jivesoftware.smack.util.stringencoder.Base64.encode(Base64.java:64)      at org.jivesoftware.smack.util.stringencoder.Base64.encode(Base64.java:60)      at org.jivesoftware.smack.util.stringencoder.Base64.encodeToString(Base64.java:42)      at org.jivesoftware.smackx.caps.EntityCapsManager.generateVerificationString(EntityCapsManager.java:707)      at org.jivesoftware.smackx.caps.EntityCapsManager.generateVerificationString(EntityCapsManager.java:581)      at org.jivesoftware.smackx.caps.EntityCapsManager.updateLocalEntityCaps(EntityCapsManager.java:477)      at org.jivesoftware.smackx.caps.EntityCapsManager.(EntityCapsManager.java:309)      at org.jivesoftware.smackx.caps.EntityCapsManager.getInstanceFor(EntityCapsManager.java:374)      at org.jivesoftware.smackx.caps.EntityCapsManager$1.connectionCreated(EntityCapsManager.java:115)      at org.jivesoftware.smack.tcp.XMPPTCPConnection.initConnection(XMPPTCPConnection.java:649)      at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:851)      at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:364)      at poc.Hangout.main(Hangout.java:35)

Can somebody help me through this setup ?

Outcomes