PHP Code, Setup and Demo of Jaxl boshchat application

PHP Code, Setup and Demo of Jaxl boshchat application

Jaxl 2.0 bosh support allow web developers to write real time web applications within minutes, without having any pre-requisite knowledge about the XMPP protocol itself. In this blog post, I will walk you through setup and demo of an XMPP based web chat application using Jaxl library.

Get the code
Follow the following steps to download and install this sample web application on your systems:

Setup web chat application
Jaxl library is default installed under /usr/share/php/jaxl folder. Application code for our web chat application can be found under /usr/share/php/jaxl/app/boshchat folder.

Follow these steps to setup web chat application on your system:

  • I assume you have http://localhost/ configured on your local web server and it runs out of /var/www folder. Create following symlinks:
    [email protected]:~/git/JAXL# cd /var/www
    [email protected]:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/boshchat.php index.php
    [email protected]:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/jaxl.ini jaxl.ini
    [email protected]:/var/www# ln -s /usr/share/php/jaxl/env/jaxl.js jaxl.js
    [email protected]:/var/www# ln -s /usr/bin/jaxl jaxl.php

    Edit/Remove #!/usr/bin/env php inside jaxl.php if it causes any problem on your system.

  • Open and edit jaxl.ini
    define('JAXL_BOSH_COOKIE_DOMAIN', false);
  • I assume you have access to XMPP over Bosh enabled jabber server. Ejabberd users can verify this by hitting http://localhost:5280/http-bind in the browser
  • Open and edit index.php
    define('BOSHCHAT_ADMIN_JID', '[email protected]');

    All messages sent using this web chat application will be routed to BOSHCHAT_ADMIN_JID

Ready for the demo
To run this example web chat application, visit http://localhost in your browser window. Enter a username/password already registered on your jabber server and press connect.

Login as BOSHCHAT_ADMIN_JID using a desktop client, so that you can receive messages sent from the browser on your desktop client.

Below is a screenshot when I logged in as “abhinavsingh” from browser and BOSHCHAT_ADMIN_JID was set to “[email protected]”:


  1. Pingback: Tweets that mention PHP Code, Setup and Demo of Jaxl boshchat application | Abhi's Weblog --

  2. samual

    I want to run the web chat application from my server to use google talk , I made suitable chages as you mentinoned above except symlinks .
    Log is

    pls help how could i run this

  3. samual

    Hi Abhinav,
    I want to run the web chat application from my server to use google talk , I made suitable chages as you mentinoned above except symlinks .
    Log is
    body content=’text/xml; charset=utf-8′ hold=’1′ xmlns=’’ wait=’30’ rid=’2080′ version=’1.6′ polling=’0′ secure=’true’ xmlns:xmpp=’urn:xmpp:xbosh’ to=’’ route=’′ xmpp:version=’1.0′
    pls help how could i run this

  4. Pingback: Releasing Jaxl 2.0 – Object oriented XMPP framework in PHP | Abhi's Weblog

  5. samual

    So I can not create a application that connects to using http-bind BOSH. I am still not sure should I have to install any jabber server on my server to connect I have installed jaxl libraries as you mentioned in this blog.I am tryin to create a web application that can use facebook chat.can you elaborate this as the above explains only for localhost(single user), what to do in case of web applications where many users can access the chat service concurrently .I am very confused.

    Please explain..

  6. Hi Samual,

    Jaxl library is capable of connecting a user to any bosh supported jabber server be it on localhost or elsewhere. Facebook chat doesn’t expose bosh end point directly for 3rd party developers (i think so).

    You will require bosh connection manager that serves as a mediator handling HTTP requests from your clients and communicating with facebook chat server.

  7. samual

    ok, so i need to install some bosh enabled jabber server on my end , can you explain how echobot application working without using any client manager on my end, does it not using any http-bind

  8. Hi Samual,

    Your questions remind me of my initial experience with XMPP, i had exactly same doubts and problems. Lemme explain:

    Facebook runs a jabber server bind to (default port 5222). Command line echobot application interact with this jabber server, directly speaking core XMPP protocol. (RFC-3920 and RFC-3921).

    To make XMPP communication possible over HTTP, there are a few extensions of XMPP protocol defined (XEP-0124 and XEP-0206). Bosh chat application utilizes these XEP’s to allow XMPP over HTTP.

    In short, Facebook server allow communication using XMPP spec’s defined in RFC’s but not using spec’s defined in XMPP over Bosh XEP’s. And hence, echobot app can connect to facebook chat servers directly but not bosh chat app.

    Hope the explanation helps 😀

  9. Pingback: Jaxl 2.0 – Installation, Usage guide and Example apps | Abhi's Weblog

  10. jitesh tandel


    I want to develop web based chat application using ruby with xmpp.and i m running out my time for that possible using ruby? and if possible then please guide me..


  11. zak

    Hey Abhi,

    I am attempting to run jaxl boshchat on localhost. I have ejabberd setup and I have verified that boshchat is working by going to http://localhost:5280/http-bind.

    When I go to login my user, it doesn’t complete. jaxl.log says that there was an internal-server-error, “BOSH module not started”. I can’t find any documentation that explains this problem. Any suggestions?

    1. Hi Zak,

      “BOSH module not started” seems to be an error from ejabberd setup. However to confirm the same can you email me complete jaxl.log file, so that i can dig a level deeper. Email address can be found at top of any core jaxl library files.

  12. Hi Zak,

    The log file tells very little about the details of the problem. I see a valid request going from Jaxl library, ejabberd fails to issue a new session id and end up throwing a “BOSH module not started” error.

    If you know a little erlang,
    will tell you why you get such an error from ejabberd.

    Kindly restart ejabberd server in debug mode (loglevel 5) which will help you know in detail why ejabberd failed to issue a new sid for connecting bosh client.

    Let me know your findings, will be happy to know/fix if it’s really because of a bug inside Jaxl library (doesn’t seems like though). Seems more like a case of wrongly configured ejabberd.

    What’s the system configuration where you are getting this error?

  13. ZZB

    Hi Abhinav,
    I followed the step. But the website stop at the secreen that button shows me “connecting…”. And i tried to use POST a directly command to jaxl.php. the website shows me “Jaxl requires curl_init method …”. I use ejabberd2.1.5, and i successed the “jaxl echobot.php” command. Anyway, the log file didn’t save what the situation i encountered. I’d ever try wireshard to konow what happened. And it shows me the web browser achieve to send the POST. But it wouldn’t do anything further.
    Thanks for reading this!

  14. ZZB

    Hi Abhi,
    I already installed php5 and curl before. But the php was installed in /usr/share/php5 and i installed jaxl in /usr/share/php/jaxl. I set the JAXL_LOG_LEVEL=5 already. However, the jaxl log in /var/log still didin’t show any thing when i tried to connect boshchat and push the connect button(But the jaxl still working when i type the “jaxl echobot.php” in command line). Thanks for your response!

    1. Hi ZZB,

      Alright then we are sure php5 and curl are well setup. It’s not a problem if you choose to keep Jaxl core under /usr/share/php/jaxl, it’s absolutely perfect if you shift Jaxl core to somewhere else too.

      Just a wild guess, if you are working with apache2-php5 setup can you try running Bosh chat example again after removing #!/usr/bin/env php from top of jaxl.php. Further if this doesn’t work for you can you provide the following detail:

      a) What’s the browser url of boshchat sample example?
      b) When you push connect button, what’s the ajax POST endpoint url? (use firebug console to see this)
      c) Can you see ajax POST request in your web server access log?
      d) Does ajax POST request receive a response from the server? If yes, what is it? (empty or [] or can be anything else)
      e) What’s the directory path (e.g. /var/www) where you have setup boshchat sample example?

  15. ZZB

    I removed the #!/usr/bin/env php. And boshchat still can’t work. But interesting, echobot.php also can’t work. It showed
    /usr/bin/jaxl: line 1: ?php: No such file or directory
    /usr/bin/jaxl: line 2: syntax error near unexpected token `(”
    /usr/bin/jaxl: line 2: `/* Jaxl (Jabber XMPP Liberary)

    a) http://localhost/index.php
    b) http://localhost/jaxl.php
    c) It showed – – [(Time i accessed)] “POST /jaxl.php HTTP/1.1” 200 329 “http://localhost/index.php” “Mozilla/5.0(X11; U; Linux i686; en-US; rv: Gecko/20100915 Ubuntu/10.04 (lucid Firefox/3.6.10)”
    d) Do u mean the response shows in firebug’s Console->Persist->Response? If yes, it showed “Jaxl requires curl_init method…”.
    e) /usr/share/php/jaxl/app/boshchat , and i made links under /var/www/ like ur article.

    I very appreciate you to answer my questions. I’m new in this area. Pleas feel free to answer me. Thanks :)!

    1. Alright then it definitely means that curl_init method does not exists or not yet supported in your web environment.

      Here is how you can check for this:
      a) Did you restart php5 and your web server after installing php5-curl?
      b) Check if phpinfo(); shows support for curl from your browser.

  16. ZZB

    Hi Abhi,
    It’s my stupid fault! My php.ini hadn’t set right when i ran ur boshchat sample. It’s working now! I’ll keep going on my plan to build my chat program by JAXL.
    Thanks a lot! 😀

  17. ZZB

    Hi Abhi,
    I encountered a new problem here. When i connected the website itself, it worked. However, when i used another computer to connect to this server, it stuck in “connecting…”. The firebug showed me “payload is null. if(payload.length == 0) {; } from jaxl.js line 102”.
    And the jaxl.log told me “Not authed yet, “Not commiting session” and {“auth”:false}.

  18. januzi

    Could somebody provide less advanced demo ? All I need is a php script that connects to the jabber/bosh, logs as specific user and sets presence to the date(). Other things like refreshing, ajax, etc. I’ll be able to write on my own.

  19. ZZB


    I’m trying to use your boshchat example to let two people can talk to each other. Finally it worked recently in Firefox. But when I want to use Safari or IE today, it didn’t work. I could sign in with account I created. However, the site didn’t show me the presence(like [email protected]/jaxlxxxxx is now online). And when I used alert() to test it. The jQuery/ajax in jaxl.js didn’t receive payload from user’s browser(Firefox can). I originally thought that maybe I modified some codes in your app, but when I test your boshchat now, it can’t work in IE and Safari anymore. Can you give me any advises? Thanks.

  20. Hi ZZB,

    The sample application codes were never tested by me on browsers other than Firefox.

    However, there is no reason as to why sample apps will not work on IE/Safari. You will need to take care of cross browser compatibility issues. Appropriate steps going forward will be:
    -> Does jaxl.php receive your browser ajax polls?
    -> If NO, then kindly modify the browser side ajax calling code as per your needs
    -> If YES, then does jaxl.php respond back appropriately to these ajax calls?

    These problems have more to do with browser compatibilities and not Jaxl library core. Feel free to submit patches for these sample examples as you sort out such cases.

  21. januzi

    Thanks for reply. I’m looking for a simple script that would run in background (setTimeout() + $.ajax) and: log to the account (with bosh, so it would stay online) and set presence (http_referer, ip, etc).

    I get: Catchable fatal error: Object of class JAXL could not be converted to string in xxx/jaxl/xep/jaxl.0206.php on line 69
    which is:
    $xml .= ” route=’xmpp:”.$host.”:”.$port.”‘”;

  22. januzi

    Nevermind. I removed all files and fetched them again from the git.
    It works, but ejabberd goes crazy. One request generates 9 “dead” connections. 10 people can easily boost amount of connections to the 15k+ :/

    1. Hi Januzi,

      Can you brief me by what do you mean by “One request generates 9 dead connections”?
      Also kindly set logLevel=5 inside your Jaxl applications and send across jaxl.log to me so that i can have a deep look into the issues you are facing.

      From your comments I understand here is what you want to do:
      1) User gets connected using bosh
      2) User stay connected using bosh and periodically you want to update it’s presence etc

      If yes then the example application under /app/boshchat does exactly the same for you.

  23. ZZB

    Hi Abhi,
    It’s interesting that I didn’t change anything but IE and Safari can work today. Anyway, do you have any examples about how to use TLS encryption in jaxl liberary? Or you can just hint me some points. Thanks a lot!

  24. januzi

    There are several states of connections (established, time_wait, fin_wait, etc). Time_wait belongs to the connections that somehow got broken or ended to early (port is still open, waiting for lost data). When one user connects to the bosh I see 4-9 connections in time_wait state. The more users, the more waiting connections. I managed to lower that amount to the 60-70 TIME_WAIT connections with 10 logged users.
    This would be good, but for some reason at one point it just “explodes”. It goes straight up from the 60 T_W to the 15000 T_W in several seconds.

    Maybe there is a bug in my code and, for example, different people gets connected to the accounts that still have got running sessions ?

    1. Hi Januzi,

      I think you are concerned about the waiting connections on the server side (ajax request hanging on jaxl.php). Is it? By design, Jaxl Bosh support will always have one connection waiting for response for a connected client. As new ajax requests are sent, previous one are replied back immediately, maintaining maximum 1 open connection per connected account. Depending upon your application you will have to adjust values for Bosh wait time, apache max child and max connection settings. You might also want to look into keep alive timeout settings.

      Finally, there are loads of approaches on how to make these thing work in a different way and using Jaxl intelligently can get you maximum throughput with minimum server resources required at your end 😀

  25. januzi

    Yep. It should be one connection. Unfortunately ejabberd generates several connections after one login request:
    netstat -a | grep :5280
    tcp 0 0 *:5280 *:* LISTEN
    tcp 0 0 bosh_server:36782 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36784 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36781 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36791 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36783 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36786 bosh_server:5280 TIME_WAIT
    tcp 0 0 bosh_server:36785 bosh_server:5280 TIME_WAIT

    More logged users, more “movement” gives more connections. At some point it goes out of control. There are so many connections (that does nothing) that make whole machine very slow. For example pages won’t load because “server is responding too slow”.
    That’s the main problem.

    1. I will probably quote down the netstat for Jaxl IM production servers. Jaxl IM currently manages a few thousands of login requests (DIGEST-MD5/ANONYMOUS) per day and I never experienced any slowness on the website due to this. However currently Jaxl IM project is under server/data migration and I will paste the netstat data when it is back in business.

  26. ZZB

    Hi Abhi,

    Did you see my question about how to use TLS in boshchat demo? I tried two days but still couldn’t make it worked. Can you kindly give me any advises?


    1. Hi ZZB,

      Sorry missed out your comment. You don’t have to enable TLS explicitly for boshchat demo. This is taken care by your underlying bosh connection manager (localhost:5280) depending upon your initial bosh request stanza <body … wait=’30’ rid=’1792′ version=’1.6′ polling=’0′ secure=’true’ …/>. Correct me if i m wrong 😉

  27. ZZB

    Hi Abhi,

    I’m happy that you replyed me. I saw what you posted in my jaxl.log. But honestly, it’s just my curiosity about your JAXL library. I found that there has the startTLS in xmpp.send.php, and when I traced code, I knew that boshchat didn’t go into there. I have some questions:
    1. Is secure=’true’ representing SASL authentication?
    2. If I want to starttls to ejabberd, the point is in ejabberd configure?
    Thank you very much!

  28. ZZB

    Hi Abhi,
    I still have some questions I found this night. Does your boshchat application have connection manager(CM)? Or the CM is exist in ejabberd server? Because I saw a ejabberd.log and package from a client log in, and the boschchat sends HTTPRequest to ejabberd, not a XML stream that CM should send defined in XEP-0124. So I guess the CM is in ejabberd. Am I right? If yes, it’s possible to use JAXL library write my own CM? Actually, I want to divide the CM and XMPP server in different computer. Correct me if I am wrong. I’m still new in PHP and XMPP. You are really helpful to me. Thanks a lot!


    1. Hi ZZB,

      Absolutely right, BOSH Conn. Manager is provided by your local ejabberd instance. Jaxl library BOSH support is a bridge between your user browser and ejabberd BOSH conn. manager via your PHP written Jaxl application code. However, you need not have separate boxes for CM and XMPP server (until unless the traffic is blowing your servers away)

      Yes it is very much possible to develop custom BOSH CM using Jaxl library itself. We at Jaxl IM have developed many such custom solutions for ourselves and also for our freelancing/consultancy customers.

  29. maschingan

    Hello Abhi,
    I still can’t understand, should I have to install any jabber server on my PC or not?
    And if not, how can i connect,for example to, what shoud i change in jaxl.ini or index.php?

    1. Jaxl is a client library and treat it equivalent to your desktop Gtalk or Pidgin client. Only difference is instead of a GUI you configure everything yourself.
      Hence Jaxl library doesn’t need a local server to play with, you can simply connect with your gtalk, jabber or facebook account to play with it.

      Checkout the latest dev branch which will be released as 2.1.2 in a week or so.
      2.1.2 will remove all kind of dependencies from, jaxl.ini, jaxl.conf or anything else which feared initial Jaxl adopters.

      Checkout latest updated sample applications which now run from command line like:
      /path/to/php echobot.php

  30. ZZB

    Hi Abhi,
    I’m trying your newest jaxl library in github. It seems better than old cause the code is more concise. However, when I tried the bochchat app, it worked fine untill I press “Disconnect”. The boshchat app couldn’t disconnect correctly, and when I saw firebug, it seems the JAXL didn’t return disconnect to client(acutally, the “disconnect” successed to send to ejabberd). And when I saw the jaxl.log, between the old version(stable one), the failed one didn’t print [[BoshOut]] about disconnect. Thanks for your answering.

  31. ZZB

    Hi Abhi,
    I’m happy I found where the problem was by my own. Inside jaxl.0124 file function preHandler, “JAXLPlugin::execute(‘jaxl_post_disconnect’);”, and the JAXLPlugin::execute should send $payload and $jaxl. So I trimmed this line to “JAXLPlugin::execute(‘jaxl_post_disconnect’,$payload, $jaxl);”, then the “disconnect” can work correctly. Correct me if I am wrong. Thanks! 😀

  32. nanu


    Great work with the xmpp library you have created!

    I got the echobot to work from command line and then moved over to try this Jaxl BoshChat app to work. Could not get it running – I see the connect button change to “connecting” state – but nothing after that… maybe there is some instructions missing for windows XP? I installed ejabberd from processone website. The link http://localhost:5280/http-bind shows that the module is running.

    For all the ln -s instructions you have listed, I copied the appropriate files into the wamp www directory. The last link you have –
    [email protected]:/var/www# ln -s /usr/bin/jaxl jaxl.php
    has a directory as the source and jaxl.php as the link name. So my copy method could not be used here. Could this be causing issues on windows?

    If anybody has this running on xp, I need some tips to get it running!!!


    1. Hi mbax,

      Set logLevel=5 inside your application code and check jaxl.log file. Most probably your destination jabber host is unreachable. If you are unable to debug kindly open an issue by clicking this and attach your jaxl.log with the issue (provide all necessary details so that i can replicate your problem at my end). Alternately you can start a new discussion on

  33. FULL LOG with level 5
    [1:5460:0] 2011-03-01 15:55:20 – [[JAXL]] No callbacks for shutdown
    [1:5460:0] 2011-03-01 15:55:20 – [[JaxlAction]] connect
    [1:5460:0] 2011-03-01 15:55:20 – [[JAXL0124]] Loading session data
    {“uid”:11,”user_name”:”admin”,”gid”:”(1,2)”,”pid”:1,”csv_array”:{“headers”:[“Campaign Name”,”Date Sent”,”Comments”,”Sent To”,”Sent”,”Pending”,”Error”],”1″:[“Test”,”Mar 1 2011 12:00AM”,” “,100,0,100,0]},”jaxl_auth”:”connect”,”jaxl_sid”:”ea6d65a4″,”jaxl_rid”:2406}
    [1:5460:0] 2011-03-01 15:55:20 – [[JAXL]] Calling JAXL0206 method startStream
    [1:5460:0] 2011-03-01 15:55:20 – [[JAXL0124]] Not authed yet, Not commiting session
    {“uid”:11,”user_name”:”admin”,”gid”:”(1,2)”,”pid”:1,”csv_array”:{“headers”:[“Campaign Name”,”Date Sent”,”Comments”,”Sent To”,”Sent”,”Pending”,”Error”],”1″:[“Test”,”Mar 1 2011 12:00AM”,” “,100,0,100,0]},”jaxl_auth”:”connect”,”jaxl_sid”:”ea6d65a4″,”jaxl_rid”:2406}
    [1:5460:0] 2011-03-01 15:55:20 – [[XMPPSend]] body
    [1:5460:0] 2011-03-01 15:55:21 – [[JAXL]] Calling JAXL0206 method out
    [1:5460:0] 2011-03-01 15:55:21 – [[JAXL0124]] Curl errno 7 encountered. Failed to connect with http://localhost:5280/http-bind/
    [1:5460:0] 2011-03-01 15:55:21 – [[BoshOut]]
    [{“jaxl”:”curlError”,”code”:7,”msg”:”couldn’t connect to host”}]

  34. Madana

    Hi Abhinav,

    Wat to do “bosh end point is unreachable”.. What is next step i can do.. Please kindly tell me solutions…

    Actually iam using linux ubuntu…

    i followed your steps fully.. its working upto login screen..

    After that they asking about username/password????

    actually i changed jaxl.ini file username and password – [email protected] / 123456, the h
    ostname also changed into “”.

    These things i given into login.. but there is not result..

    And i didnt get anything in jaxl.log file also…

    please help me..

  35. JRE

    hi, i have the same problem to try to connect to gtalk server

    [{“jaxl”:”curlError”,”code”:7,”msg”:”couldn’t connect to host”}]

    JAXL vr. 2.1.2

  36. madana

    Hi Abhi,

    Ejabberd is working fine..
    The registered user in ejabberd are below
    [email protected] (admin)
    [email protected]
    [email protected]

    When the “Web Chat Application using Jaxl Library” login screen

    username : [email protected]
    password : xxxxxx

    The connecting button only displays.. there is no reactions..

    After that i tried to change jaxl.ini file
    username : madan123
    password : xxxxxx
    hostname :

    for sample application under /usr/share/php5/jaxl/app/echobot

    i runned this command in terminal jaxl echobot.php

    iam getting this below things..

    [4536] 2011-03-22 17:22:47 – Registering shutdown for SIGH Terms …
    [4536] 2011-03-22 17:22:47 – Openssl enabled …
    [4536] 2011-03-22 17:22:49 – Socket opened to the jabber host …
    [4536] 2011-03-22 17:22:55 – Performing Auth type: DIGEST-MD5
    [4536] 2011-03-22 17:23:00 – Auth completed…

    jaxl.log file
    [3713] 2011-03-22 16:50:58 – [[XMPPSend]] 92

    [3713] 2011-03-22 16:56:57 – [[XMPPGet]]

    Pls tell me a solutions for this..

  37. Madana

    Hi Abhi,

    I used Jaxl 2.1.0 version only.. Now i downloaded the jaxl 2.1.2-rc1 version, after i exact that folder but there is no such file.. how to start installation??? or shall i copy file from older version.. shall i proceed like that??

    Please advise me..

  38. Madana

    Hi Abhi,

    After extract new version of jaxl, i copied into var/www path and usr/share/php5/ ..

    Remove the old version files inside the php5 folder..

    I was runned http://localhost/jaxl/app/boshchat.php

    “Web chat application” page is displaying..

    I entered username : gmst
    password : xxxxx
    clicked connect button.. still showing connecting button , no actions are been taken..

    I dont know wats going on the behind the jaxl chat application…

    jaxl.log file
    It displays the “internal server error – BOSH module is not started “…

    Wat to do for start bosh??

  39. Arto L.

    Hi, I have problem with page refreshing. I have chat built on boshMUChat code, which automatically creates dummy ejabberd user and room (using php auth). User info and room is stored in session. On otherside I have admin account which can see all rooms & talk to those.

    User joins the room on page load using Javascript
    var obj = new Object;
    obj[‘user’] = ‘User123’;
    obj[‘pass’] = ‘dummypassword’;

    Problem is that when user reloads the page, he gets disconnected from chat and when he tries to enter new message Firebug returns empty array []. After ~1min admin can see in room that the user have disconnected & after that when user next time reloads the page he’ll re-join the chat.

    Is there some way to re-connect to current session when page is reloaded? On workaround is to give jaxl.disconnect on window.unload event, but this method is not bulletproof…

  40. Arto L.

    Ok got that fixed, stupid mistake by me. I had commented out $html from getPresence (didn’t want to display that info to user), and didn’t notice that if $html is empty it won’t return correct values.

  41. Anna

    I have this error while I trying to run:
    jaxl echobot.php
    /usr/bin/jaxl: line 1: ?php: No such file or directory
    /usr/bin/jaxl: line 2: syntax error near unexpected token `(‘
    /usr/bin/jaxl: line 2: `/* Jaxl (Jabber XMPP Library)’

    I have installed curl and I can see it enabled at phpinfo(). Could you please help me?

  42. Tomas

    Hello Abhi,

    you wrote, that you’re gonna wrote something about installation on Windows server, how is it going? 🙂

    I’m just new in JAXL, I don’t know where to start and it would be nice, if you wrote it for beginners like me.

    Thx for response.

  43. Harshad

    Hello Abhinav,

    I have tried your library and it works great.
    I have a issue I need your help with, when I try the demo boshchat client from apps folder it works great, but when I try to send message using only php and no javascript it doesn’t work, I want to send message to multiple uses in a loop using php but can’t get it to work, can you please tell me what should I do in order to make in work without JavaScript, my ejabberd logs show that jaxl connects to server just fine but message is not delivered.

    Thanks and Looking for your response.

    1. you should send messages in one single go…. i.e. you can create several packets, but send them in one go. This way Jaxl won’t break the php session locking required to work from browser apps (i suppose this is that must be causing issue for you if you tried to send multiple packet in a loop).

      You can do it in two ways: Either by directly using XMPPSend::message($jaxl, …..) where every other parameter to this function should be an array(). Size of array equals to number of packets you are trying to send. Alternately, you can use XMPPSend::prepareMessage($jaxl, ….) to create raw Xml packets on by one. When you are done creating them all, you can directly send the xml packet over the wire.

  44. Antonio

    Hello Abhinav,
    first thanks for your work.
    I’m testing your webchat with bosh and it works well.
    But in the page that containing it, I would like to show the presence of admin who receive message from webchat.
    How can I do?
    In boshchat class there is a function called getPresence, that I think it display when an users do login/logoff from the webchat. So it isn’t good (and doesn’t work).

    1. basically you need to login user into an account, which receives admin presence info on signup. Alternately you can send a presence probe stanza to check if admin is online/offline and display the info accordingly.

  45. Harshad

    Hello Abhinav, I have made some changes to boshChat.php so that it can connect with existing jaxl session, but after reconnecting when I try to pass the jaxl id I receive payload is empty error:

    Here is the code
    case ‘reconnect’:
    $response = array(‘jaxl’=>’reconnected’, ‘jid’=>$jaxl->jid);
    $jaxl->JAXL0206(‘out’, $response);


  46. anamika saxena

    dear Abhinav,

    hi, i m anamika. I have a problem about chatting that how only 2 pesons can chat and other can’t……plz tell me n i hv downloaded ur Jaxl boshchat application, but i couldn’t find that prob. which i hv mentioned above. plzz help me..

  47. stella0302


    Thanks for good work!

    I would like to use facebook chat function on my web app. My questions are:

    1. I have a php script that connects to facebook chat server to do the authentication,send/receive msg. How to push/receive msgs to/from the web client? Is using bosh the only way to achieve this goal? Is there any way that I can let other php scripts share this socket?

    2. In your jaxl bosh chat app, who is the http cm, who is the server? Is the php on the local host a bosh server, or is XMPP server a bosh server, the php on your localhost is a http CM?

    Look forward your kind reply!

  48. German

    I have a problem about authentication in chat, but in my case, I have openfire server running in VirtualBox, I can connect to it but in the conexion, the server don’t authenticate my user, shown in the log

    and my user is register in openfire server, an answer?

    PD: sorry, my english is bad!! XD

  49. I would like to know if, with JAXL, I can programmatically logon and set the MOTD (mod_announce) on an ejabberd server.

    I am building an Admin console in php and cannot find a tutorial anywhere on how to do this.

    Please point me in the right direction.


    1. you need right permissions…. jaxl is unable to create a log file… try to pass `’logPath’=>’/tmp/jaxl.log’` which should get this fixed for you…. alternately update the permissions as required

  50. Carlos Perez

    Hi. I have a problem with Jaxl. I created a class for a boshchat client based on the code of the boshchat example. Basically it works, I can authenticate and send and receive messages for a while.

    The problem is that after a couple of minutes the jaxl object from jaxl.js starts sending continuous ping requests and chat stops working. Can’t send or receive any more messages.

    I checked the log file and found that ‘sid’ is missing and it reports “<body type='terminate' condition='improper-addressing' …

    I'm including a fragment of the log file, so you can see when it happens.

    Thanks and look forward your reply.

    [1:2851:0] 2012-05-18 13:48:46 – [[XMPPSend]] body

    [1:2849:0] 2012-05-18 13:48:47 – [[XMPPGet]]

    [1:2850:0] 2012-05-18 13:48:47 – [[XMPPSend]] body

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPGet]]

    [1:2852:0] 2012-05-18 13:49:17 – [[XMPPSend]] body

    [1:2852:0] 2012-05-18 13:49:17 – [[XMPPGet]]

    [1:2850:0] 2012-05-18 13:49:17 – [[XMPPGet]]

    [1:2849:0] 2012-05-18 13:49:17 – [[XMPPSend]] body

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPSend]] body

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPGet]]

  51. Carlos Perez

    Hi. Looking at the first version of Jaxl I tested, 2.1.2rc1, found that disconnection happens exactly a minute after the first ping starts. With 2.1.2rc2 is random, just a time between 1 and 2 minutes after the first ping request.

    I’m using JAXL0206 like in boshchat.php to keep the connection alive, but also tried with JAXL0199. With that one only got continous ping requests.

    I included a piece of the jaxl.log file before, but was not right. Will include it again.

    Thanks in advance.

    [1:2851:0] 2012-05-18 13:48:46 – [[XMPPSend]] body
    body rid=”4160″ sid=”d6f58abe46c1f8ce3b9f48ac70d215576076a615″ xmlns=””/

    [1:2849:0] 2012-05-18 13:48:47 – [[XMPPGet]]
    body xmlns=’’/

    [1:2850:0] 2012-05-18 13:48:47 – [[XMPPSend]] body
    body rid=”9763″ sid=”3b5c8ca5ae4f930dab2365924976bbeaea00b3fb” xmlns=””/

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPGet]]
    body xmlns=’’/

    [1:2852:0] 2012-05-18 13:49:17 – [[XMPPSend]] body
    body rid=”8228″ sid=”” xmlns=””/

    [1:2852:0] 2012-05-18 13:49:17 – [[XMPPGet]]
    body type=’terminate’ condition=’improper-addressing’ xmlns=’’/

    [1:2850:0] 2012-05-18 13:49:17 – [[XMPPGet]]
    body xmlns=’’/

    [1:2849:0] 2012-05-18 13:49:17 – [[XMPPSend]] body
    body rid=”9764″ sid=”3b5c8ca5ae4f930dab2365924976bbeaea00b3fb” xmlns=””/

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPSend]] body
    body rid=”8229″ sid=”” xmlns=””/

    [1:2851:0] 2012-05-18 13:49:17 – [[XMPPGet]]
    body type=’terminate’ condition=’improper-addressing’ xmlns=’’/

  52. Carlos Perez

    Hi again 🙂

    Excuse me for sending a message again. Here is ejabberd’s log file. You can see the disconnection because of a session timeout. It looks like ejabberd server doesn’t see http_poll requests and session expires. I also modified the timeout at the server, but now it closes connection after 2 minutes instead of 1 even when I set timeout to 5 minutes.

    =INFO REPORT==== 2012-07-05 12:16:16 ===
    I(:ejabberd_listener:232) : (#Port) Accepted connection {{127,0,0,1},49148} -> {{127,0,0,1},5280}

    =INFO REPORT==== 2012-07-05 12:16:16 ===
    I(:ejabberd_http:138) : started: {gen_tcp,#Port}

    =INFO REPORT==== 2012-07-05 12:16:35 ===
    I(:ejabberd_http_bind:508) : Session timeout. Closing the HTTP bind session: “9b4cfcc9730fc862a6e4be6d0f39245fa07e1d74”

    =INFO REPORT==== 2012-07-05 12:16:35 ===
    I(:ejabberd_c2s:1409) : ({socket_state,ejabberd_http_bind,{http_bind,,{{127,0,0,1},49038}},ejabberd_http_bind}) Close session for [email protected]/jaxl.1.1341483271

    I also installed Openfire to test a different server. It takes longer to disconnect, but in the end it does. With Firefox and Chrome takes longer, but with opera disconects in a few seconds.

    This is the message in Openfire’s log file when server disconnects client.

    2012.07.05 14:57:25 org.jivesoftware.openfire.http.HttpBindServlet – Client provided invalid session: . []

Comments are closed.