powered by Jive Software

XMPPWebSocketConnection for Android using AndroidAsync

Based on https://github.com/koush/AndroidAsync

and https://code.google.com/p/openfire-websockets/

I tried creating a smack-android-websocket similar to smack-bosh

I am attaching the JAVA programs,

Currently the tags are hard coded inside the code

It seems the websocket plugin does not accepts initiation

This will only work for android application
XMPPWebSocketConnection.java (10836 Bytes)
XMPPWebSocketConfiguration.java (2874 Bytes)

Thanks for sharing.

BTW you wouldn’t be interested in contributing smack-websocket, smack-websocket-androidasync, smack-websocket-javax (using The Central Repository Search Engine )

This may be some amount of work and sure will require some code reviews. But it would be highly appreciated.

How to do the contribution?

I would recommend that you join #smack (freenode), ideally with an bnc or another mechanism that allows you to stay permanently in the channel. Experience shows that IRC is an ideal way to coordinate development.

Make sure to read https://github.com/igniterealtime/Smack/wiki/Guidelines-for-Smack-Developers-and -Contributors and to coordinate everything regarding development with me.

Have you been able to test this solution successfully?

I am in need of xmpp working through WebSockets.

yes, with the current code it should work the websocket plugin https://code.google.com/p/openfire-websockets/,

if you want additional iq stanza processing you need to code inside https://code.google.com/p/openfire-websockets/

Hey Zigma,

First thing many thanks for your help and code you provided, thanks to it I was able to implement the WS support into our system.

Hope to see you on some conference, and get you at least a beer.

Do you work on providing Smack community WSConnection support?

I would be interested in working on that too, and would like ask you where are you, and if you accept submissions.

with best wishes,



currently I am identifying few issues in general…

connectivity with openfire…

with all three type of connection (websocket, tcp-socket, bosh)…

in all three type of medium (browser, desktop, mobile)…

If I got time, I will contribute…in all above 6 things … including openfire pugins

Can you update code for 4.1.6 Smack version?

it seems a new open fire web socket plugin officially released on Jan 6, 2016


Readme Doc: Openfire WebSocket Plugin Readme

But it is in Alpha stage

Please find the attached websocket code with some improvements You can use the latest AndroidAsync 2.1.7, But I only tested with 2.1.3, let me know in case
XMPPWebSocketConnection.java (14668 Bytes)
XMPPWebSocketConfiguration.java (3012 Bytes)

Hi @Zigma,

I have included these two classes for websocket connection in my Android project. After login, I am getting error while binding resource with the server and hence server does not respond to pings beacuse of which the websocket closes. Can you help me in understanding what is the problem here and how can this be rectified?


websocket ping does not help much, you should detect the socket closure and reconnect.

paste the error which you are getting.

Hi @Zigma,

I’ve included these two classes in my android project, but I’m unable to connect to the server (I’m getting org.jivesoftware.smack.SmackException: Timeout reached for the connection to null:0 but I don’t have any idea why). Can you help me understand what am I doing wrong?

The libraries that I’m using are:

ps. I am attaching code on how I am trying to establish the connection.
connection.rtf (1.1 KB)