I have a Java Server application which talks to other apps/servers. It has to also talk to a XMPP Server on behalf of multiple users. So using up one port per user is not an option. So I thought of using BOSH (a minor hack on BOSH actually, to not ping the server on receiving a response, but pinging only before the inactivity time expires on the XMPP server for the Bosh Connection). I also want to set the "wait" time on the BOSH connections to a minimum, so that the server returns the response immediately. All this to not hold up ports too long.
I was looking at the different XMPP Java-based Client libraries supporting BOSH and the only one which I got working was the Tigase JaXMPP library(after some hacks on it). But I am unable to use that on my project due to the licensing model. Another option was Smack, but I realised that they do not support BOSH yet in the official release(Its on a branch, which is not really active, I think). Does anyone know any other options for this requirement?
When I was reading more, I found Strophe.js - which supposedly has great support for BOSH - but that seems more for a web-based application. Does anyone know how I can make calls to the Strophe functions from my java code and also is there anyway I can modify the Strophe.js library to set different wait times on the BOSH connection and also not ping the server when a response is received, rather only before the inactivity time expires?
Any insights or ideas are appreciated.
I see a couple of options for you...
The first option is for your app to connect as a server component (XEP-0114) to generate the messages. This allows any process to have a persistent connection to the XMPP server over which it can transmit messages. Some servers (Prosody, ejabberd and possibly others) will even allow a component to 'spoof' messages from any JID they like.
Component support in XMPP servers is almost universal, which is great. Additionally many libraries in various languages support acting as components, so you should have a lot of flexibility (unfortunately I don't know the Java libraries well to give specifics on them).
The second option is slightly less standardized, but depending on your app you might find it easier. Some servers support feeding messages to them over protocols other than XMPP. For example for Prosody you will find mod_post_msg, and for ejabberd mod_http_message. Both allow the server to accept messages submitted as HTTP POST requests, which really couldn't get any simpler, just about every language can make HTTP requests in a few lines.
The disadvantage of this approach is that it isn't portable between XMPP servers, but it's a simple enough task, and it shouldn't be hard to do in whichever server you choose to use.