Web chat using Strophe and Apache Vysper


I was told about Apache Vysper by a colleague at work and thought I’d give it a try. It is very much in development and lacks documentation, but it is very easy to get started. It does not have clustering support though.

In this post I’ll replace Openfire in the web chat setup I did in a previous post. You’ll need a more feature-rich client than trophyim to add users to a roster (contact list) and such. I use Jitsi.

Setup Vysper

Grab a copy of Vysper version 0.7. Extract it to any folder. You’ll need a JVM to run the server. Before doing that, let us configure a few things by editing the config file spring-config.xml in the config folder.

Locate the following lines and change the domain name (your machine name should do fine or localhost):

<!-- TODO change domain name to your domain -->
<constructor-arg value="localhost"/>

Locate the following lines and change the admin user domain and password. Add more users if you wish.

<bean id="addUsers" class="org.apache.vysper.spring.AddUserHelper">
    <constructor-arg index="0">
        <map>
            <entry key="admin@localhost" value="passw0rd" />
            <entry key="friend@localhost" value="passw0rd" />

Uncomment the following line (thus enabling the BOSH):

<ref bean="boshEndpoint"/>

Uncomment the BOSH endpoint configuration:

<bean id="boshEndpoint" class="org.apache.vysper.xmpp.extension.xep0124.BoshEndpoint">
    <property name="accessControlAllowOrigin">
        <list><value>*</value></list>
    </property>
    <property name="port" value="8080" />
    <property name="contextPath" value="/bosh" />
</bean>

Start Vysper

Head to the command line and execute run.bat or run.sh from the bin folder. If all goes well you can access http://localhost:8080/bosh/ from the browser.

Execute trophyim

You’ll need to change the variable TROPHYIM_BOSH_SERVICE in the trophyim.js file, assign 'http://localhost:8080/bosh/'. Open index.html in the browser (using a file:// url), that should launch trophyim. You can use a client like Jitsi to setup contacts, and then test chatting with them using trophyim.

Note that we do not require an http server and proxy, as in the previous post, I suspect Vysper supports W3C CORS out of the box. That is good news indeed.

12 thoughts on “Web chat using Strophe and Apache Vysper

  1. Hi,
    I followed the same steps as mentioned in the article.when i try to access the http://localhost:8080/bosh i get the following error
    Error 405
    Problem accessing /bosh/. Reason:
    This is an XMPP BOSH connection manager, only POST is allowed
    Can you help me out

    Regards
    Aruna

    1. Hi Aruna, sorry for not making it obvious in the post, but that is the right message. You can proceed with trying to execute trophyim.

  2. Sir,
    i have very liittle experience with vysper…
    i don’t know how the users will be registered, how contacts will be saved, how groups will be maintained…
    i have used openfire but now developing a web app in j2ee thinking of embedding vysper…
    waiting for your valuable reply………….

    1. Hi Praveen, Vysper is still very much in development. I know that an admin console is in the works. The default persistence is in-memory. They have support for a JCR backend but it is not stable. They also have a Cassandra based backend submitted by the community, but it is not integrated into the main code base. If you are looking to study XMPP what they have is good enough. If you require something more robust and stable, you can take a look at Openfire.

  3. Nice post Devendra, I started looking for quick startup of running standalone vysper and came up here through google.
    Vysper has provided an interface which you can implement on your own to write a jdbc connection to a database as well, as an enhancement

  4. Sir,
    May I ask how to add contact through Jitsi,
    since I have no idea how to login to my vyser server
    by Jitsi…
    Thanks anyway for your sharing~

    1. The entry keys you provided in the “spring-config.xml” are the accounts
      the “key” is used as “username” and the “value” is used as “password”

  5. Hi
    I followed the same steps as mentioned in the article.when i try to open the index.html and input user and password, I get the following error in the server of vysper:
    15:20:34,424 | ERROR | org.apache.vysper.xmpp.extension.xep0124.BoshServlet | Exception thrown while decoding XML
    java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.startAsync()Ljavax/servlet/AsyncContext;
    at org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext.insertRequest(BoshBackedSessionContext.java:558)
    at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.createSession(BoshHandler.java:287)
    at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.process(BoshHandler.java:135)
    at org.apache.vysper.xmpp.extension.xep0124.BoshSaxContentHandler.emitStanza(BoshSaxContentHandler.java:90)
    at org.apache.vysper.xmpp.extension.xep0124.BoshSaxContentHandler.endElement(BoshSaxContentHandler.java:78)
    at org.apache.vysper.xml.sax.impl.XMLParser.endElement(XMLParser.java:480)
    at org.apache.vysper.xml.sax.impl.XMLParser.token(XMLParser.java:238)
    at org.apache.vysper.xml.sax.impl.XMLTokenizer.emit(XMLTokenizer.java:154)
    at org.apache.vysper.xml.sax.impl.XMLTokenizer.parse(XMLTokenizer.java:86)
    at org.apache.vysper.xml.sax.impl.XMLParser.parse(XMLParser.java:121)
    at org.apache.vysper.xml.sax.impl.DefaultNonBlockingXMLReader.parse(DefaultNonBlockingXMLReader.java:185)
    at org.apache.vysper.xmpp.extension.xep0124.BoshDecoder.decode(BoshDecoder.java:81)
    at org.apache.vysper.xmpp.extension.xep0124.BoshServlet.doPost(BoshServlet.java:176)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    at org.eclipse.jetty.server.Server.handle(Server.java:346)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
    can you help me to slove it, thank you very much!!

  6. Hi

    i will be really greateful if you post a blog related to how we can enable xmpp over websockets in vysper

    Thanks in advance,

    Vinay

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s