When will the HTTP Binding feature be available on Connection Manager?

Hello Wildfire dev,

I’‘ve found the “org.jivesoftware.multiplexer.net.http” package appeared on connection manager SVN during Oct 14 ~ 17. From the source code, we can learn that the package is for HTTP Binding (JEP-0124). But the connection manager doesn’'t have any update for nearly one week. So could Alex or someone in Jivesoftware give us a schedule of this feature? I believe there are also some other people like me waiting for HTTP binding support. I have evaluated some third party HTTP Binding module such as JabberHTTPBind, but they are not so good at scalability. So I think have HTTP Binding support on Connection Manager is good choice.

Thanks,

Tim

Tim,

For the most part HTTP Binding is code complete in both the connection manager and wildfire. There are some minor things that need to be tweaking in order to completly conform with the XEP but for the most part things seem to be in working order. We have not yet had the chance yet to test it extensivly but that should be happening in the next few days. Thanks for the interest, and if you have any more questions feel free to let us know.

Thanks,

Alex

Good news! I will be eagerly anticipating this as well.

Cheers,

Jeff

Message was edited by: jsegal

Alex,

Is everything included in the latest Nightly Build? If so, how do we access/configure it? If not, when can we expect it to show up in the Nightly Builds?

Thanks.

It is not yet in the nightly builds, the code is on a branch is SVN. It should be available in the nightly builds soon.

Thanks,

Alex

I’'ve tested the Connection Manager again, everything goes fine except the inactivity problem.

I’'ve created a Java client myself according to XEP-0124:

  1. create session and get sid from server

  2. sasl

  3. bind resource and send presence

  4. keep sending blank body using the sid from step 1 in interval 10s (default server inactivity timeout = 30s, polling=5s, my wait=15s).

But the server disconnect me with a 403 error after 30 ~ 40 seconds(between step 1 and disconnect) and the sid has been expired from server. So from now all the packet send to server will get a 404 error.

from HttpSessionManager.java,

public void reset(HttpSession session) {
    stop(session);
    if(session.isClosed()) {
        return;
    }
    InactivityTimeoutTask task = new InactivityTimeoutTask(session);
    schedule(task, session.getInactivityTimeout() * 1000);
    sessionMap.put(session.getStreamID(), task);
}

I found there is a schedule task here, the task itself just close the session. Is there anything wrong here? Or maybe something is wrong in my code.

BTW, My test client runs well using JabberHTTPBind.

Hey Tim,

Would it be possible for you to forward me your code? So, I can then figure out where the logic is incorrect on the session timeout side.

Thanks,

Alex

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import sun.misc.BASE64Encoder; /** * A simple HTTP Binding (XEP-0124) client * @author Tim (freetmp (at) msn.com) * */
public class HttpBindClient {
     public static final String URL_BASE = "http://dev1:8080/";
     public static final String XMPP_DOMAIN = "dev2";
     private String username = "tim";
     private String password = "test";
     
     public static final int HOLD = 1;     
     public static final int WAIT = 15;      private int rid;
     private String sid;
     private boolean hasAuth = false;
     
     private URL u;      private HttpURLConnection con;
     private long bootTime = System.currentTimeMillis();      public HttpBindClient() {
          rid = new Random(System.currentTimeMillis()).nextInt(1000000);
     }      public void run() {
          try {
               u = new URL(URL_BASE);
          } catch (MalformedURLException e) {
               e.printStackTrace();
          }           createSession();
          auth();
          if (hasAuth)
               presence();
          else
               System.out.println("Auth failed.");
     }      public void createSession() {
          String result = routePacket(null);
          Pattern p = Pattern.compile(".*\\<body.*sid=[''\"]([^''\"]+)[''\"].*\\>.*");
          Matcher m = p.matcher(result);
          if (m.matches()) {
               this.sid = m.group(1);
               System.out.println("Get sid: " + this.sid);
          }
     }      public void auth() {
          // use sasl plain
          String jid = username + "@" + XMPP_DOMAIN;
          String src = jid + "\0" + username + "\0" + password;
          BASE64Encoder enc = new BASE64Encoder();
          String encStr = enc.encode(src.getBytes());
          
          String auth = "<auth mechanism=\"PLAIN\" xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" +
                    encStr + "</auth>";
          String result = routePacket(auth);
          if (result.indexOf("<success") != -1)
               this.hasAuth = true;
     }      public void presence() {
          String xmlBind =  "<iq id=\"420000-1\" type=\"set\">" +
                    "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" +
                    "<resource>eclipse</resource>" +
                    "</bind></iq>";
          String xmlPresence = "<presence id=\"420000-2\"></presence>";
          
          routePacket(xmlBind);
          routePacket(xmlPresence);
          
          // keep the connection every 10 sec
          while (true) {
               routePacket(" ");
               try {
                    Thread.sleep(10000);
               } catch (InterruptedException e) {
                    e.printStackTrace();
               }
          }
     }
     
     private String routePacket(String src) {
          String result = null;
          try {
               String packet = null;
               if (src == null)
                    packet = buildCreatePacket();
               else
                    packet = buildPacket(src);
               
               byte[] cmd = packet.getBytes("utf-8");                con = (HttpURLConnection) u.openConnection();
               con.setRequestMethod("POST");
               con.setDoOutput(true);
               con.setDoInput(true);
               con.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
               con.setRequestProperty("Content-Length", String.valueOf(cmd.length));
               con.connect();                OutputStream os = con.getOutputStream();
               os.write(cmd);
               
               int retCode = con.getResponseCode();
               if (retCode != 200) {
                    System.out.println("ERROR: " + retCode);
               }
               
               InputStream in = con.getInputStream();
               BufferedReader br = new BufferedReader(new InputStreamReader(in));
               String line = null;
               StringBuilder buf = new StringBuilder();
               while ((line = br.readLine()) != null)
                    buf.append(line);
               br.close();
               os.close();                result = buf.toString();
               System.out.println("R: " + result);
          } catch (IOException e) {
               e.printStackTrace();
               System.out.println("Get error, time elapsed: " + (System.currentTimeMillis() - bootTime) / 1000);
          }
          
          return result;
     }
     
     private String buildCreatePacket() {
          StringBuilder sb = new StringBuilder();
          return sb.append("<body content=\"text/xml; charset=utf-8\" hold=\"").append(HOLD)
               .append("\" rid=\"").append(rid++).append("\" to=\"").append(XMPP_DOMAIN)
               .append("\" secure=\"false\" wait=\"").append(WAIT)
               .append("\" xml:lang=\"en\" xmlns=\"http://jabber.org/protocol/httpbind\"></body>")
               .toString();
     }
     
     private String buildPacket(String content) {
          StringBuilder sb = new StringBuilder();
          sb.append("<body rid=\"").append(rid++).append("\" sid=\"").append(sid).append("\"")
               .append(" xmlns=\"http://jabber.org/protocol/httpbind\">");
          sb.append(content);
          sb.append("</body>");
          System.out.println("S: " + sb.toString());
          return sb.toString();
     }      public static void main(String[] args) {
          new HttpBindClient().run();
     }
}

Hey Tim,

It wasn’'t the inactivity timer that was the problem I had incorrect logic in my polling interval check which was causing the 403 error, Too Frequent Polling. I have checked in the fix and everything seems to be in working order now.

Thanks,

Alex

Thanks, Alex

It works after checking out the svn code.

Tim

BTW, everyone should check out Alex’'s HTTP Binding post:

http://jivesoftware.com/blog/2006/10/26/wildfire-http-binding/

-Matt

Hi Alex ,

Thanks for adding such a wonderful feature !!

I have downloaded the latest milestone (Wildfire 3.2.0 Alpha 0) which seems to have http bind functionality in built , i enabled the it at admin console .

I am trying out JcJac simple client example but got errors-> http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/cvs/jsjac/examples/simpleclient. html?rev=1.16&view=markup

also how to make this work with jwchat

I guess it must be pretty simple now , but there no documentation on how to make it work …I really want to test this feature

Any pointers wub be appreciated

What errors are you getting?

Thanks,

Alex

Hi Alex .

Thanks for fast respond

I am getting this error when I try to run -> JSJaC (same library used in Jwchat) Simple Client -> bundled with download -> http://jabberstudio.org/projects/jsjac/releases/view.php?id=821

with following values

Backend Type -> Http Polling

HTTP Base -> http://MyServerName:9090

Jabber Server -> ServerName

[Exception… Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) nsresult: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED)

location: JS frame :: file:///home/gp/Desktop/Drawer/download/oct/jsjac-0.5/JSJaCHttpPollingConnectio n.js :: JSJaCHPCConnect :: line 136" data: no]

In admin console -> http binding I have tried both ->Use Admin Console Ports and -> Use Distinct Ports

Regards,

pagux

Message was edited by: pagux2jabber

Pagux,

Try setting the backend type to “binding” instead of polling.

tried setting Backend Type HTTP Binding gives the same error

[Exception… "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) " nsresult: “0xc1f30001 (NS_ERROR_NOT_INITIALIZED)” location: “JS frame :: file:///home/gp/Desktop/Drawer/download/oct/jsjac-0.5/JSJaCHttpBindingConnectio n.js :: JSJaCHBCConnect :: line 216” data: no]

Has any body succeeded in testing new http Binding with JsJac ?

I’'m getting the same thing with JWChat.

Alex, what’'s the HTTP Base we should be using when trying to connect?

One of the issues you are facing is that the http-bind service must be running on the same domain. We currently don’'t have a finished solution for how this will be handled, the ability to load the chat client directly into Wildfire, so in the mean time I have been proxying requests through an apache server. So, for instance, if you get the chat client from http://localhost/ the binding service will need to be running on localhost. So, I setup a proxy in apache, whose web-root would contain jwchat, which forwards requests on http://localhost/http-bind/ to http://wildfire:9090/http-bind. Where wildfire:9090 is the server running my http bind service.

As i said this is a temporary solution until we work something better out, if you need anymore information on how to implement this - let me know.

Alex

hello,

i’'ve installed wildfire in an attempt to run jwchat on a test website.

i’'m running wildfire nightly build version 3.2.0 alpha with http binding on a debian stable.

First i’‘m not quite sure where it comes from or if it’'s been discussed already but it seems that the http binding admin page has some problems applying/modifying the params you set.

Basically i believe the daemon can’'t release the ports you set in the custom ports, when changing them and pushing the save button, it falls back to “disabled” and netstat shows the ports are still active. When you select the admin console ports then it applies the setup successfully.

Don’‘t get me wrong the custom ports do work for http binding, i’'m using 8080 on my test server.

So back to my jwchat problem…

According to your remark above, my wildfire and jwchat are served on the same subdomain.

I’'ve configured jwchat and apache to work together and it seems to be okay.

I can create user accounts in wildfire from the jwchat login page, then i get the popup user window and an “online” sound (i can see the online icon for a second), but then quite instantly i get a js error message informing me of an “Internal Server Error - Disconnedted - Reconnect ? yes/no”…

I suspect it’‘s a proxy setup problem but i can’‘t find any debug output so i’'m not sure where to look for debug info.

Any ideas ?

thx

webdev

Message was edited by: webdev

Hmmm… well there can be several things that are going on here. When i was testing with JWChat i was having trouble with both its polling interval, it violated the minimum polling interval, and Apache was having trouble because the connections were being kept open too long without a response, this was even after increasing the proxy timeout time in Apache (if anyone has any ideas on this, please let me know). So, what i did to resolve the second issue was decreasing the wait to 10 seconds, the connection would fail with a 502 Proxy Error otherwise.

How did I go about diagnosing and resolving these issues? Two firefox extensions:

  • firebug

  • Live HTTP Headers

Firebug you to debug the javascript, so, you can easily go in an determine whats going on. And, Live HTTP Headers, allows you to see the headers being sent to and from firefox, though regrettably not the response body, so you can determine if it is something like a 502 error.

Thanks,

Alex