Set Timeout during XMPP login

102 views
Skip to first unread message

sylver

unread,
Oct 13, 2008, 3:05:14 AM10/13/08
to SamePlace/xmpp4moz
Hi,

Just a quick one. Can we set timeout value during user login? another
parameter for the XMPP.up()

var account = {
jid : 'art...@earth.org/Guide',
password : '42',
connectionSecurity : 1
};
XMPP.up(account);

Is there any other attributes beside the ones below? :
* jid: full JID, including resource (if not provided, will be
prompted (but other fields on the object will be ignored))
* password: password (if not provided, will be prompted, but as
long as jid is set, will keep other fields set on the object)
* connectionHost: host (if different from the domain part of the
JID)
* connectionPort: port (if different from 5223)
* connectionSecurity: SSL (0 or 1; 1 is default)

Thanks :D

Brett Zamir

unread,
Oct 13, 2008, 10:23:24 AM10/13/08
to same...@googlegroups.com
Hi,

There is no such option (at least at present).

Also, the docs really should all be up to date now for all public
methods (the events pages need some clean up though). There's also a
wiki page on internals that covers some functions in more depth
(assuming I outlined them fully accurately--but I should have at least
discussed all possible eventualities evident in the functions where not
covered in the API now). But the API docs should, I think, all be
comprehensive and valid.

best wishes,
Brett

sylver

unread,
Oct 14, 2008, 3:18:57 AM10/14/08
to SamePlace/xmpp4moz
Thanks for your reply.

I looked through the API docs yesterday and found no entry on this
matter too.

Is there a way to cut off the "connecting" session (the one where the
progress bar appear at bottom-right of the browser) so that users know
they need to relogin? Hiding the progress bar didn't help much.

Thanks :D

Brett Zamir

unread,
Oct 17, 2008, 8:49:19 AM10/17/08
to same...@googlegroups.com
Hi,

I understand that xmpp4moz will try to connect again on its own, so if I'm not clear on what you're asking.

There is an event for 'connecting' which you can listen for if that helps...:

var channel = XMPP.createChannel(CHANNEL_FEATURES);
channel.on ({
            event : 'connector-connecting',
            state : 'connecting'},
            function () {alert("we're still connectinggggg...");}
);

Brett

sylver

unread,
Dec 12, 2008, 11:10:27 AM12/12/08
to SamePlace/xmpp4moz
Thanks for your reply,

Will take a look an it and post my result here.

:D

Brett

unread,
Dec 12, 2008, 3:14:13 PM12/12/08
to SamePlace/xmpp4moz
I'm very sorry, I said that wrong.... It should be:

var channel = XMPP.createChannel(CHANNEL_FEATURES);
channel.on ({
event : 'connector',
state : 'connecting'},
function () {alert("we're still connectinggggg...");}
);


Brett

sylver

unread,
Dec 18, 2008, 1:17:41 AM12/18/08
to SamePlace/xmpp4moz
Thanks for the code. It works :D

The way the above code works is when a stream is created (tries to
login) an alert box will appear, correct? are there any other states
for this type of event?

The wiki @ http://github.com/bard/sameplace/wikis/api-event seems to
be missing the states:
[...snip...]
Event: connector

Generated when incoming or outgoing XML streams are open. Properties:

* event – “connector”
* direction – “in” or “out”
* state -
[...snip...]

Is there any way of achieving this:

begin
xmpp.up(account, function(){ connectSuccess(); }); //assuming
account is defined
var tmr = setTimeout("failToConnect()", 15000); // 15secs timout

function failToConnect(){ alert("Sorry...try again"); }

function connectSuccess(){
alert("Connected!");
clearTimeout(tmr);
}
end

Thanks :D

Brett Zamir

unread,
Dec 18, 2008, 3:11:05 AM12/18/08
to same...@googlegroups.com
Hi,

On 12/18/2008 2:17 PM, sylver wrote:
> Thanks for the code. It works :D
>
> The way the above code works is when a stream is created (tries to
> login) an alert box will appear, correct? are there any other states
> for this type of event?
>
> The wiki @ http://github.com/bard/sameplace/wikis/api-event seems to
> be missing the states:
> [...snip...]
> Event: connector
>
> Generated when incoming or outgoing XML streams are open. Properties:
>
> * event – “connector”
> * direction – “in” or “out”
> * state -
> [...snip...]
>
>

These are detailed at http://github.com/bard/sameplace/wikis/api-channel
. Feel free to update the api-event page, if you like :)

My patch aims to also add:
1) Addresses potential stream-level errors: "sasl-error", "tls-error",
"session-error". (Authentication is a type of SASL error.)
2) Stream features: "features".
3) Changing the 'active' state to return (as with a proposed 'bound'
state) the JID bound by the server (e.g., if the server decides to
change or add a resource, as the spec allows it to do, you'd have a way
to get it).

> Is there any way of achieving this:
>
> begin
> xmpp.up(account, function(){ connectSuccess(); }); //assuming
> account is defined
> var tmr = setTimeout("failToConnect()", 15000); // 15secs timout
>
> function failToConnect(){ alert("Sorry...try again"); }
>
> function connectSuccess(){
> alert("Connected!");
> clearTimeout(tmr);
> }
> end
>

There is nothing in the API to specifically control timeouts, but that
doesn't mean you couldn't use one.

In the xmpp4moz source, I see there are only two one-shot 3-second
timeouts (at the beginning of an outgoing stream and after starting
TLS), timeouts which simply lead to one additional reconnect attempt.
(There is also another 30 second timer which continually repeats after a
session has been established, simply sending whitespace to the server to
keep the connection alive.)


FYI, in debugging, I was able to do the following to trace the
connection events as they took place for me:

var prompts =
Cc['@mozilla.org/embedcomp/prompt-service;1'].getService(Ci.nsIPromptService);
var temp = '';


channel.on (
{event : 'connector'},

function (el) {
temp += el.state+' : ';
prompts.alert(null, 'Session Error', temp);
}
);

The last alert here gave me:

connecting : wait-stream : stream-open : features :
auth-waiting-result : wait-stream : stream-open : features :
binding-resource : bound : requesting-session : idle :

(note that features and bound are my own states, not currently in
xmpp4moz, but it may give further indication of what is going on)

Maybe you could come up with some timeout that considered the current
state and the apparent fact that only one reconnect attempt is made
(e.g., I imagine "connecting" might not show up a third time).

Or maybe you could also simply periodically check whether the connection
is still up with XMPP.isUp()?

I'm sorry but I don't quite understand this fully either, but maybe the
above can help you figure something out, if Massimiliano doesn't have
anything to suggest...

best wishes,
Brett

Reply all
Reply to author
Forward
0 new messages