sstrigler/JSJaC

"Unspecified error" from _process

Closed this issue · 8 comments

I've got a program working great in Firefox and Chrome but in Internet Explorer 8 on Windows XP, I get an "Unspecified Error" on line 3872 (of the uncompressed version). It seems that this._req is undefined? What am I missing?

Incidentally, how do I get JSJaC to NOT delay several seconds before sending messages?

Am 29.08.2011 um 04:06 schrieb paullckby:

I've got a program working great in Firefox and Chrome but in Internet Explorer 8 on Windows XP, I get an "Unspecified Error" on line 3872 (of the uncompressed version). It seems that this._req is undefined? What am I missing?

Sorry, guess that's a hard one. You're not "missing" anything. I remember I had such an issue some years ago at one of my customers but unfortunately I can't remember exactly how we solved the issue. It was not an error with jsjac itself but somewhat about how and when all things are being initialized. Are you using the onload event to start using jsjac?

Incidentally, how do I get JSJaC to NOT delay several seconds before sending messages?

Is this also IE8 only or does it happen to you on any platform?

Found the problem. I was running my web application on www.lockaby.org but my HTTP-BIND path was on im.lockaby.org. This configuration apparently works with Firefox and Chrome but NOT Internet Explorer. I changed it to be on the same host in the same domain and now it works.

As for the delay, that happens on every platform. It sends the post eventually, but only after it hits the 30 second timeout. Is there a way to force the connection to flush its buffer?

Am 29.08.2011 um 13:33 schrieb paullckby:

As for the delay, that happens on every platform. It sends the post eventually, but only after it hits the 30 second timeout. Is there a way to force the connection to flush its buffer?

No sorry, there's no such thing. There must be some problem with your setup still. JSJaC flushes it's queue every 100ms or such automatically (you can tweak this value by changing JSJAC_CHECKQUEUEINTERVAL).

Further information: jsjac will wait until the server sends something -- such as a presence notification -- then start a new connection where the first thing it does is send the message before it too closes. Then a third notification starts. So the timeline is like this:

  1. client sends a message, nothing happens
  2. long connection terminates because server pushes something to the client
  3. new long connection started
  4. client finally actually sends the message from step 1 and the long connection terminates again
  5. new long connection
  6. go to step 1

I'm skeptical that it is a configuration issue on my end because there were no problems when I was using strophe, but strophe but I didn't like strophe for reasons left unsaid.

This behavior has been reported to me several times but I haven't been able to ever reproduce it myself with jsjac. Funny thing is that I had this behavior with strophe some time ago.

Which version of jsjac are you using exactly? Please try setting the property 'timerval' when creating the JSJaCHttpBindingConnection like:

var con = JSJaCHttpBindingConnection({'httpbase': '/http-bind/', 'timerval': 1});

Also please show me exactly which arguments you're passing to the inherit method.

Am 30.08.2011 um 00:14 schrieb paullckby reply@reply.github.com:

Further information: jsjac will wait until the server sends something -- such as a presence notification -- then start a new connection where the first thing it does is send the message before it too closes. Then a third notification starts. So the timeline is like this:

  1. client sends a message, nothing happens
  2. long connection terminates because server pushes something to the client
  3. new long connection started
  4. client finally actually sends the message from step 1 and the long connection terminates again
  5. new long connection
  6. go to step 1

I'm skeptical that it is a configuration issue on my end because there were no problems when I was using strophe, but strophe but I didn't like strophe for reasons left unsaid.

Reply to this email directly or view it on GitHub:
#24 (comment)

This example duplicates the problem.

<?php

require_once dirname(__FILE__) . "/jaxl/core/jaxl.class.php";

session_start();

        $xmpp = new JAXL(array(
            'user'       => 'user1',
            'pass'       => 'XXXX',
            'domain'     => 'lockaby.org',
            'boshHost'   => 'localhost',
            'boshPort'   => 5280,
            'boshSuffix' => 'http-bind',
            'boshOut'    => false,
            'logLevel'   => 6,
            'logPath'    => '/dev/null'
        ));

        // include the XMPP over BOSH XEP
        $xmpp->requires(array('JAXL0206'));

        // Register callbacks for required events
        $xmpp->addPlugin('jaxl_get_auth_mech', 'jaxl_get_auth_mech');
        $xmpp->addPlugin('jaxl_post_auth', 'jaxl_post_auth');

        $_SESSION['jaxl_jid'] = $xmpp->jid;

        // fire start Jaxl in bosh mode
        $xmpp->startCore('bosh');

    function jaxl_get_auth_mech($mechanism, $jaxl) {
        $jaxl->auth('PLAIN');
    }

    function jaxl_post_auth($payload, $jaxl) {
        $response = array('jaxl' => 'connected', 'jid' => $jaxl->jid);
        $jaxl->JAXL0206('out', $response);
    }

?>
<html>
    <head>
        <script type="text/javascript" src="jsjac-1.3.4.js"></script>
        <script type="text/javascript" src="jquery-1.6.2.js"></script>
        <script type="text/javascript">
            var connection = undefined;

            jQuery(document).ready(function () {
                var jid_object = new JSJaCJID('<?=$_SESSION['jaxl_jid']?>');
                var username = jid_object.getNode();
                var domain = jid_object.getDomain();
                var resource = jid_object.getResource();

                // disable JSJAC keys because inherit doesn't work with them
                // and JSJAC doesn't automatically disable them for whatever reason
                JSJAC_HAVEKEYS = false;

                // generic args method for passing to jsjac
                var args = null;

                args = new Object();
                args.httpbase = '/http-bind';
                args.timerval = 1;
                connection = new JSJaCHttpBindingConnection(args);

                // attach to the existing session that we've been given by php
                args = new Object();
                args.username = username;
                args.domain = domain;
                args.resource = resource;
                args.sid = '<?=$_SESSION['jaxl_sid']?>';
                args.rid = parseInt(<?=$_SESSION['jaxl_rid']?>);
                connection.inherit(args);

                // send some messages across the wire
                // request the roster
                var iq = new JSJaCIQ();
                iq.setIQ(null, 'get', 'roster');
                iq.setQuery(NS_ROSTER);
                connection.send(iq);

                // send initial presence
                connection.send(new JSJaCPresence());

                setTimeout(foobar, 2000);
            });

            function foobar() {
                // send a message to test2
                var message = new JSJaCMessage();
                message.setTo(new JSJaCJID('test2@lockaby.org'));
                message.setBody('foobar');
                connection.send(message);
            }
        </script>
    </head>
    <body>
    </body>
</html>

As properties of args to inherit() you must also set

polling
inactivity
requests

as returned by the initial response from the BOSH service.

So your code might look like this:

args = new Object();
args.username = username;
args.domain = domain;
args.resource = resource;
args.sid = '';
args.rid = parseInt();
args.polling = parseInt();
args.inactivity = parseInt();
args.requests = parseInt();
connection.inherit(args);

It may also be necessary to set the 'wait' attribute as well.

Am 30.08.2011 um 14:06 schrieb paullckby:

This example duplicates the problem.

'user1', 'pass' => 'XXXX', 'domain' => 'lockaby.org', 'boshHost' => 'localhost', 'boshPort' => 5280, 'boshSuffix' => 'http-bind', 'boshOut' => false, 'logLevel' => 6, 'logPath' => '/dev/null' )); // include the XMPP over BOSH XEP $xmpp->requires(array('JAXL0206')); // Register callbacks for required events $xmpp->addPlugin('jaxl_get_auth_mech', 'jaxl_get_auth_mech'); $xmpp->addPlugin('jaxl_post_auth', 'jaxl_post_auth'); $_SESSION['jaxl_jid'] = $xmpp->jid; // fire start Jaxl in bosh mode $xmpp->startCore('bosh'); function jaxl_get_auth_mech($mechanism, $jaxl) { $jaxl->auth('PLAIN'); } function jaxl_post_auth($payload, $jaxl) { $response = array('jaxl' => 'connected', 'jid' => $jaxl->jid); $jaxl->JAXL0206('out', $response); } ``` ?> <script type="text/javascript" src="jsjac-1.3.4.js"></script> <script type="text/javascript" src="jquery-1.6.2.js"></script> <script type="text/javascript"> var connection = undefined;
           jQuery(document).ready(function () {
               var jid_object = new JSJaCJID('<?=$_SESSION['jaxl_jid']?>');
               var username = jid_object.getNode();
               var domain = jid_object.getDomain();
               var resource = jid_object.getResource();

               // disable JSJAC keys because inherit doesn't work with them
               // and JSJAC doesn't automatically disable them for whatever reason
               JSJAC_HAVEKEYS = false;

               // generic args method for passing to jsjac
               var args = null;

               args = new Object();
               args.httpbase = '/http-bind';
               args.timerval = 1;
               connection = new JSJaCHttpBindingConnection(args);

               // attach to the existing session that we've been given by php
               args = new Object();
               args.username = username;
               args.domain = domain;
               args.resource = resource;
               args.sid = '<?=$_SESSION['jaxl_sid']?>';
               args.rid = parseInt(<?=$_SESSION['jaxl_rid']?>);
               connection.inherit(args);

               // send some messages across the wire
               // request the roster
               var iq = new JSJaCIQ();
               iq.setIQ(null, 'get', 'roster');
               iq.setQuery(NS_ROSTER);
               connection.send(iq);

               // send initial presence
               connection.send(new JSJaCPresence());

               setTimeout(foobar, 2000);
           });

           function foobar() {
               // send a message to test2
               var message = new JSJaCMessage();
               message.setTo(new JSJaCJID('test2@lockaby.org'));
               message.setBody('foobar');
               connection.send(message);
           }
       </script>
   </head>
   <body>
   </body>

Reply to this email directly or view it on GitHub:
#24 (comment)

Sure enough, setting those three properties made it work the way I expected it. Unfortunately, my client didn't give them to me, so I set them to 0, 30 and 2, respectively.

Thanks for your help.