powered by Jive Software

Smack BOSH Support & Smack 3.3.1 question

Hi folks,

I have a requirement to use BOSH-XMPP in one of my projects and I was looking at the Smack library for it. Came across a few related bugs in the forums, which are reportedly being fixed in 3.3.1?

Does anybody know when 3.3.1 is coming out?

Thanks a lot,


Looks like BOSH support is on a separate branch, which is not merged with Smack yet. Am I correct?

Any plans to merge that into the mainline with 3.3.1?


No there are no merge plans right now. The bosh branch also switches the build system from ant to maven. I hope that this switch is done in the near future because the longer these two branches are separated the more the code will diverege and the harder the merge will get.

You could simply cherry pick the 3 java classes related to BOSH and add the jbosh library to you project. This should enable BOSH support. aSmack does that.

OK. Thanks for the update. I saw on some forum topics about some BOSH related bugs in 2012(may be even 2013), do you know if they have been merged into the BOSH branch?

Can you give me a link to the BOSH branch? I can check out the code and build it myself using maven.

What is aSmack, is that another library? I will look around on it.

Thanks again.

If there is no bug report that is closed then it’s likely that no code got commited. You find the BOSH branch as one of the various branches within Smack’s svn. I recommended to not use the branch directly since it’s pretty old and various other bugs have been fixed in the mean time. That’s why I recommend to copy the BOSH related files and add jbosh to your project.

aSmack is the Android port of Smack.

I am assuming that this is what you are saying and what I did was the same:

I used the nightly builds to get the smack jars and then went and got the 3 inidividual files like below.

http://fisheye.igniterealtime.org/browse/smack/branches/bosh/smack-bosh/src/main /java/org/jivesoftware/smack/BOSHConfiguration.java?r=11324

and the other two in similar fashion.

Will give it a shot.

Hi Flow,

Please help!

I gave it a shot and am stuck with this issue now. I am unable to connect to the server from my test client.

Looks like the request never hits the server. I am pretty sure the url is fine as I can do the same on the browser. I am using the Tigase XMPP Server and it does support BOSH.

Timeout reached for the connection to null:0.: remote-server-timeout(504) Timeout reached for the connection to null:0.

at org.jivesoftware.smack.BOSHConnection.connect(BOSHConnection.java:227)

at org.jivesoftware.smack.SmackBOSHExample.main(SmackBOSHExample.java:14)

This is the code I am trying to test:

package org.jivesoftware.smack;

import org.jivesoftware.smack.Connection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.packet.Presence;

public class SmackBOSHExample {

public static void main(String args[]){

BOSHConfiguration config = new BOSHConfiguration(false, “IP”, 5280, “/xmpp-httpbind”, “domainname”);

Connection conn = new BOSHConnection(config);

try {


conn.login(“userid”, “password”);

System.out.println(“Logged in user”);

Presence presence = new Presence(Presence.Type.available, “on-call”,

10, Presence.Mode.dnd);


System.out.println(“Set presence”);


System.out.println(“About to disconnect”);


} catch (InterruptedException ie) {

// TODO Auto-generated catch block


} catch (XMPPException e) {

// TODO Auto-generated catch block





The connect timesout as the packet is not sent to the server at all and hence there is no response.

When I debugged the code, I see that there are no request listeners set on the jbosh’s BOSHClient class.

The “fireRequestSent” method loops on the available listeners and it has none for this client. Not sure if this is a problem.

But one thing I am sure of is that, the request never hits the server at all.

I got jbosh and its dependencies from this location.


Do you see any issues or do you have any clues that could help?

Thanks a lot for your time,



I debugged more and found that the issue occurs when the send is triggered from the xlightsweb class, XLightWebResponse.

final HttpClient client,
final BOSHClientConfig cfg,
final CMSessionParams params,
final AbstractBody request) {

IFutureResponse futureVal;
try {
String xml = request.toXML();
byte[] data = xml.getBytes(CHARSET);

String encoding = null;
if (cfg.isCompressionEnabled() && params != null) {
AttrAccept accept = params.getAccept();
if (accept != null) {
if (accept.isAccepted(ZLIBCodec.getID())) {
encoding = ZLIBCodec.getID();
data = ZLIBCodec.encode(data);
} else if (accept.isAccepted(GZIPCodec.getID())) {
encoding = GZIPCodec.getID();
data = GZIPCodec.encode(data);

PostRequest post = new PostRequest(
cfg.getURI().toString(), CONTENT_TYPE, data);
if (encoding != null) {
post.setHeader(CONTENT_ENCODING, encoding);
if (cfg.isCompressionEnabled()) {
futureVal = client.send(post);
} catch (IOException iox) {
toThrow = new BOSHException(“Could not send request”, iox);
futureVal = null;
future = futureVal;

The iox is “java.net.ConnectException: could not connect to null:0”. Any ideas why this could happen?


I am having this too with 3.3.0. See here:

Try 3.2.2 instead. It should work.