Saturday, November 1, 2014

Version 0.4.0 now available on Maven Central

I am happy to announce version 0.4.0 of the XMPP client library "Babbler".

First of all thanks to all of you who contributed to this release (reported bugs, tested stuff, made suggestions for improvements, etc.).

There were three main requests you asked for:

  • More configuration options, especially for the connections (e.g. to set a custom SocketFactory, to set custom keep-alive intervals, etc.)
  • Modularization
  • Maven Central integration

The good news is, that this release accounts for everything of it! The bad news is that it's incomptible with the previous version, but hey, that's why it's still in development status.

More Configuration Options

The old connections only had very limited configuration options, which were passed to the constructor. Of course this didn't scale very well when the demand for more configuration options increases. Therefore there's now a configuration object, which let's you configure the connection.

Instead of passing a connection to the XmppSession, you now pass the configuration object to it. This allows you to reuse a configuration for multiple sessions. The session then creates a new connection based on the configuration.

Here's how it looks like.

There's also a configuration object for the whole XmppSession, e.g. to set a debugger. It also takes responsibility to create the JAXBContext, which was previously done in the XmppSession. This has the advantage that it doesn't need to be recreated for each new session (because it is quite expensive to create it).

Modularization

The previous version did a bad job on modularization, in fact you weren't able to only use XMPP core functionality without having to include all extensions. This version now improves on this situation. There's a better separation between core and extensions, so that you only need to include a small jar file, if you only want XMPP core functionality.

Maven Central Integration

Some people asked for it and it has always been a long-term goal: Maven Central integration. Well, it now happened earlier than I thought, this is the first version to be available on Maven Central!

They made me register a domain, so that they could assign a unique groupId: xmpp.rocks.

The new domain also made me feel like changing the package name, in order to fit the groupId and generally it's the convention to use the domain you control for the package name. Given that the API wouldn't be compatible anyway (due to the mentioned new configuration objects and also due to the modularization) I changed the package name to "rocks.xmpp" and also took the opportunity to refactor some other package names. So, if you are migrating from a previous version, you have to refresh your import statements.

Here are the coordinates:


<dependency>
    <groupId>rocks.xmpp</groupId>
    <artifactId>xmpp-core-client</artifactId>
    <version>0.4.0</version>
</dependency>
<dependency>
    <groupId>rocks.xmpp</groupId>
    <artifactId>xmpp-extensions-client</artifactId>
    <version>0.4.0</version>
</dependency>

Visual Debugger

One cool new feature is the visual XMPP viever/debugger (written in JavaFX). I've already blogged about it in my last post, but here's a small glimpse, how it looks like:

There have also been other new features, improvements and bug fixes, which are listed in the changelog.

As always: I am happy about feedback!

5 comments:

  1. Hi, I tried your project and it works perfectly fine, really easy to implement. However I wanted to use it within the Jersey RESTful Web Services framework and I'm facing an issue with JAXB due to a no-arg constructor. Below the detail of the error
    01-Dec-2014 17:55:52.911 SEVERE [http-nio-8084-exec-131] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [ServletAdaptor] in context with path [/BabblerRest] threw exception [java.lang.ExceptionInInitializerError] with root cause
    com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    rocks.xmpp.extensions.jingle.model.Jingle$Reason$AlternativeSession does not have a no-arg default constructor.
    this problem is related to the following location:
    at rocks.xmpp.extensions.jingle.model.Jingle$Reason$AlternativeSession
    at private rocks.xmpp.extensions.jingle.model.Jingle$Reason$Condition rocks.xmpp.extensions.jingle.model.Jingle$Reason.condition
    at rocks.xmpp.extensions.jingle.model.Jingle$Reason
    at private rocks.xmpp.extensions.jingle.model.Jingle$Reason rocks.xmpp.extensions.jingle.model.Jingle.reason
    at rocks.xmpp.extensions.jingle.model.Jingle
    Until now I didn't find any solution to fix this problem, can you help me with this matter? Do you know a workaround or does it requires code change in your module?

    ReplyDelete
    Replies
    1. Hi,

      I (and nobody else) ever came up with this issue. However there were reports about similar "no-args constructor" issues in the past. I think it turned out that they used an old version of Java (early 1.7) and/or old JAXB.

      I suggest maybe checking/updating the JDK and check the JAXB implementation/version. Babbler only works with the reference implementation (RI) of JAXB, (which is Metro, and the default implementation of JDK). I've once tried another JAXB implementation (Moxy), but it didn't work.

      You can also try to use the sources directly (otherwise I could also build a snapshot version).
      The fix (hopefully) is here:
      https://bitbucket.org/sco0ter/babbler/commits/fe94ee211f42b5009501197a050f0936135572eb

      Delete
  2. Hi, Your library is really handy. I am trying establish BOSH connection to a openfire server on port 7070 with firewall unblocked and openfire actively listening. Without proxy it works well with openfire running on same network but with proxy getting the following error,

    java.io.IOException: java.net.SocketTimeoutException: Read timed out
    at rocks.xmpp.core.session.XmppSession.connect(XmppSession.java:737)
    at com.geo.XMPPBosh.XMPPDemo.main(XMPPDemo.java:45)
    Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
    at rocks.xmpp.extensions.httpbind.BoshConnection$2.run(BoshConnection.java:564)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    Exception in thread "main" java.lang.IllegalStateException: You must be connected to the server before trying to login.
    at rocks.xmpp.core.session.XmppSession.login(XmppSession.java:827)
    at com.geo.XMPPBosh.XMPPDemo.main(XMPPDemo.java:52)

    Below is the code,
    BoshConnectionConfiguration boshConfiguration = BoshConnectionConfiguration
    .builder().hostname("remote address").port(7070)
    .proxy(new Proxy(Proxy.Type.HTTP,new InetSocketAddress("proxy address", 10015))).file("/http-bind/").wait(5000).build();

    Pl help on what might be the cause or the solution.

    ReplyDelete
    Replies
    1. Hi,
      I am not sure, but maybe your proxy address/port is wrong? Could you try to connect with?
      new URL("http://remoteaddress:remoteport").openConnection(proxy).connect();

      you could also get in touch with me via email: christian.schudt at gmx.de

      Delete