librelist archives

« back to archive

Prebind session and reconnect

Prebind session and reconnect

From:
Alexandre Coloma
Date:
2014-03-10 @ 23:01
Hi, im using prebind with converse, but whennmy computer enter and the
connection lost, connverse not try yo reconnect and my users has in their
screens and error messages. How can i avoid it? Some ideaa to solve it? Im
thinking in close converse controlbox when disconnect event occurs, and try
to reconnect when user click to show control box. Any better idea? Somebody
has implement something for this situation? Thanks in advance

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-12 @ 05:20
I did some work recently on letting converse.js reconnect if the connection
drops but only got it to work in the non-prebind case.

In the prebind case it didn't work, I think, because the BOSH session is lost
and there is therefore no valid BOSH session to attach to anymore.

If my assumption is correct, then you'll have to make a new BOSH connection
to reattach against.

On Tue, Mar 11, 2014 at 12:01:55AM +0100, Alexandre Coloma wrote:
>    Hi, im using prebind with converse, but whennmy computer enter and the
>    connection lost, connverse not try yo reconnect and my users has in their
>    screens and error messages. How can i avoid it? Some ideaa to solve it? Im
>    thinking in close converse controlbox when disconnect event occurs, and
>    try to reconnect when user click to show control box. Any better idea?
>    Somebody has implement something for this situation? Thanks in advance

Re: [conversejs] Prebind session and reconnect

From:
Alexandre Coloma
Date:
2014-03-12 @ 08:21
Yes, i have do it yet,
thanks for you reply,
Alex


2014-03-12 6:20 GMT+01:00 JC Brand <lists@opkode.com>:

> I did some work recently on letting converse.js reconnect if the connection
> drops but only got it to work in the non-prebind case.
>
> In the prebind case it didn't work, I think, because the BOSH session is
> lost
> and there is therefore no valid BOSH session to attach to anymore.
>
> If my assumption is correct, then you'll have to make a new BOSH connection
> to reattach against.
>
> On Tue, Mar 11, 2014 at 12:01:55AM +0100, Alexandre Coloma wrote:
> >    Hi, im using prebind with converse, but whennmy computer enter and the
> >    connection lost, connverse not try yo reconnect and my users has in
> their
> >    screens and error messages. How can i avoid it? Some ideaa to solve
> it? Im
> >    thinking in close converse controlbox when disconnect event occurs,
> and
> >    try to reconnect when user click to show control box. Any better idea?
> >    Somebody has implement something for this situation? Thanks in advance
>

Re: [conversejs] Prebind session and reconnect

From:
Ankit Bhootra
Date:
2014-03-12 @ 09:58
Thanks for your reply,

 

I understand your words.. but the problem is with roaster’s status when
prebinding first time, I am not reloading or reattaching any connection. I
am just trying to prebind the user by giving sid, jid and rid. 
also I have run and install the node and npm respectively and also run grunt
fetch as you have mentioned in the guide.. but there is no components folder
created, so I can’t even debug and check this issue 

 

thanks





 

 

From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
Of Alexandre Coloma
Sent: Wednesday, March 12, 2014 1:51 PM
To: conversejs@librelist.com
Subject: Re: [conversejs] Prebind session and reconnect

 

Yes, i have do it yet, 
thanks for you reply,
Alex

 

2014-03-12 6:20 GMT+01:00 JC Brand <lists@opkode.com>:

I did some work recently on letting converse.js reconnect if the connection
drops but only got it to work in the non-prebind case.

In the prebind case it didn't work, I think, because the BOSH session is
lost
and there is therefore no valid BOSH session to attach to anymore.

If my assumption is correct, then you'll have to make a new BOSH connection
to reattach against.


On Tue, Mar 11, 2014 at 12:01:55AM +0100, Alexandre Coloma wrote:
> Â  Â Hi, im using prebind with converse, but whennmy computer enter and
the
> Â  Â connection lost, connverse not try yo reconnect and my users has in
their
> Â  Â screens and error messages. How can i avoid it? Some ideaa to solve
it? Im
> Â  Â thinking in close converse controlbox when disconnect event occurs,
and
> Â  Â try to reconnect when user click to show control box. Any better
idea?
> Â  Â Somebody has implement something for this situation? Thanks in
advance

 

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-13 @ 02:59
On Wed, Mar 12, 2014 at 03:28:44PM +0530, Ankit Bhootra wrote:
>    I understand your words.. but the problem is with roaster’s status when
>    prebinding first time, I am not reloading or reattaching any connection. I
>    am just trying to prebind the user by giving sid, jid and rid.
>    also I have run and install the node and npm respectively and also run
>    grunt fetch as you have mentioned in the guide.. but there is no
>    components folder created, so I can’t even debug and check this issue

Ankit, you are replying to the wrong thread. Please stay on topic in
the threads.

If you are having problems with setting up the dev environment, look for errors
in your console and post them in an email to us. Put them in the OTHER thread,
the one that you created, NOT this one, which is about Alexandre's topic.


>    From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
>    Of Alexandre Coloma
>    Sent: Wednesday, March 12, 2014 1:51 PM
>    To: conversejs@librelist.com
>    Subject: Re: [conversejs] Prebind session and reconnect
> 
>     
> 
>    Yes, i have do it yet,
>    thanks for you reply,
>    Alex
> 
>     
> 
>    2014-03-12 6:20 GMT+01:00 JC Brand <[1]lists@opkode.com>:
> 
>    I did some work recently on letting converse.js reconnect if the
>    connection
>    drops but only got it to work in the non-prebind case.
> 
>    In the prebind case it didn't work, I think, because the BOSH session is
>    lost
>    and there is therefore no valid BOSH session to attach to anymore.
> 
>    If my assumption is correct, then you'll have to make a new BOSH
>    connection
>    to reattach against.
> 
>    On Tue, Mar 11, 2014 at 12:01:55AM +0100, Alexandre Coloma wrote:
>    > Ã*  Ã* Hi, im using prebind with converse, but whennmy computer enter
>    and the
>    > Ã*  Ã* connection lost, connverse not try yo reconnect and my users has
>    in their
>    > Ã*  Ã* screens and error messages. How can i avoid it? Some ideaa to
>    solve it? Im
>    > Ã*  Ã* thinking in close converse controlbox when disconnect event
>    occurs, and
>    > Ã*  Ã* try to reconnect when user click to show control box. Any better
>    idea?
>    > Ã*  Ã* Somebody has implement something for this situation? Thanks in
>    advance
> 
>     
> 
> References
> 
>    Visible links
>    1. mailto:lists@opkode.com

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-20 @ 20:48
2014-03-11 23:20 GMT-06:00 JC Brand <lists@opkode.com>:

> I did some work recently on letting converse.js reconnect if the connection
> drops but only got it to work in the non-prebind case.
>
> In the prebind case it didn't work, I think, because the BOSH session is
> lost
> and there is therefore no valid BOSH session to attach to anymore.
>
> If my assumption is correct, then you'll have to make a new BOSH connection
> to reattach against.




I'm having the same problem. Creating a new BOSH connection means asking
the username and password again, right? If so, it could be annoying for the
users.

It sems that the connection drops because of a timeout (idle timeout?). If
it is because of an idle timeout, is there any way converse.js could send
some kind of "ping" to keep the connection alive?

Regards.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-21 @ 07:37
On Thu, Mar 20, 2014 at 02:48:58PM -0600, Rodolfo Gonzalez wrote:
>    2014-03-11 23:20 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> 
>      I did some work recently on letting converse.js reconnect if the
>      connection
>      drops but only got it to work in the non-prebind case.
> 
>      In the prebind case it didn't work, I think, because the BOSH session is
>      lost
>      and there is therefore no valid BOSH session to attach to anymore.
> 
>      If my assumption is correct, then you'll have to make a new BOSH
>      connection
>      to reattach against.
> 
>     
>    I'm having the same problem. Creating a new BOSH connection means asking
>    the username and password again, right? If so, it could be annoying for
>    the users.

If you don't use prebind, then it should reconnect again automatically because
converse remembers the username and pw (at least in latest release).

If you use prebind, then converse cannot reconnect automatically because the
SID and RID it has aren't valid anymore and needs to get new ones (from the
server which prebinds).

So I think what needs to happen in the prebind case is that the server needs to
prebind again and supply a new SID and RID to converse.

>    It sems that the connection drops because of a timeout (idle timeout?). If
>    it is because of an idle timeout, is there any way converse.js could send
>    some kind of "ping" to keep the connection alive?

The BOSH connection uses long polling. A request is made and kept open by the
server until it has XMPP data to respond with or otherwise until the request
times out. If the request times out, a new request must immediately be made by
the client (i.e. converse.js).

If the client doesn't quickly enough make another request, the connection
drops.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-21 @ 11:20
2014-03-21 1:37 GMT-06:00 JC Brand <lists@opkode.com>:

>
>  If you use prebind, then converse cannot reconnect automatically because
> the
> SID and RID it has aren't valid anymore and needs to get new ones (from the
> server which prebinds).
>
> So I think what needs to happen in the prebind case is that the server
> needs to
> prebind again and supply a new SID and RID to converse.
>


But wouldn't the pre-bind script need the password for this?



> >    It sems that the connection drops because of a timeout (idle
> timeout?). If
> >    it is because of an idle timeout, is there any way converse.js could
> send
> >    some kind of "ping" to keep the connection alive?
>
> The BOSH connection uses long polling. A request is made and kept open by
> the
> server until it has XMPP data to respond with or otherwise until the
> request
> times out. If the request times out, a new request must immediately be
> made by
> the client (i.e. converse.js).
>
> If the client doesn't quickly enough make another request, the connection
> drops.
>


Is converse.js doing this?

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-21 @ 13:51
On Fri, Mar 21, 2014 at 05:20:58AM -0600, Rodolfo Gonzalez wrote:
>    2014-03-21 1:37 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> 
>       If you use prebind, then converse cannot reconnect automatically
>      because the
>      SID and RID it has aren't valid anymore and needs to get new ones (from
>      the
>      server which prebinds).
> 
>      So I think what needs to happen in the prebind case is that the server
>      needs to
>      prebind again and supply a new SID and RID to converse.
> 
>    But wouldn't the pre-bind script need the password for this?

Yes, but it's something converse doesn't concern itself with. Prebind happens
server side.
  
>      >    It sems that the connection drops because of a timeout (idle
>      timeout?). If
>      >    it is because of an idle timeout, is there any way converse.js
>      could send
>      >    some kind of "ping" to keep the connection alive?
> 
>      The BOSH connection uses long polling. A request is made and kept open
>      by the
>      server until it has XMPP data to respond with or otherwise until the
>      request
>      times out. If the request times out, a new request must immediately be
>      made by
>      the client (i.e. converse.js).
> 
>      If the client doesn't quickly enough make another request, the
>      connection
>      drops.
> 
>    Is converse.js doing this?

Javascript is single threaded. If some other expensive operation is holding up
the queue, then the next request might not be made quickly enough.

Not much converse can do about it except reconnect.

I think using websockets should remove these problems (but introduce backward
incompatibility with older browsers).

Strophe.js (which conversejs uses) now has websocket support, but I haven't
tested it or made the necessary modifications required in conversejs in order
to use it.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-21 @ 19:48
2014-03-21 7:51 GMT-06:00 JC Brand <lists@opkode.com>:

> On Fri, Mar 21, 2014 at 05:20:58AM -0600, Rodolfo Gonzalez wrote:
> >    2014-03-21 1:37 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> >
> >       If you use prebind, then converse cannot reconnect automatically
> >      because the
> >      SID and RID it has aren't valid anymore and needs to get new ones
> (from
> >      the
> >      server which prebinds).
> >
> >      So I think what needs to happen in the prebind case is that the
> server
> >      needs to
> >      prebind again and supply a new SID and RID to converse.
> >
> >    But wouldn't the pre-bind script need the password for this?
>
> Yes, but it's something converse doesn't concern itself with. Prebind
> happens
> server side.
>


I know, but that would imply storing plain text passwords somewhere,
possibly in PHP session, an idea I don't quite like. Otherwise I'd need to
ask the user for username/password over and over.



> >      If the client doesn't quickly enough make another request, the
> >      connection
> >      drops.
> >
> >    Is converse.js doing this?
>
> Javascript is single threaded. If some other expensive operation is
> holding up
> the queue, then the next request might not be made quickly enough.
>
> Not much converse can do about it except reconnect.
>
> I think using websockets should remove these problems (but introduce
> backward
> incompatibility with older browsers).
>
> Strophe.js (which conversejs uses) now has websocket support, but I haven't
> tested it or made the necessary modifications required in conversejs in
> order
> to use it.
>


I already have certain polling AJAX calls to PHP scripts running every
minute or so. Would it help, for instance, sending a ping (
http://xmpp.org/extensions/xep-0199.html) with XmppPhp, for example?

Thanks.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-24 @ 08:29
On Fri, Mar 21, 2014 at 01:48:36PM -0600, Rodolfo Gonzalez wrote:
>    2014-03-21 7:51 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> 
>      On Fri, Mar 21, 2014 at 05:20:58AM -0600, Rodolfo Gonzalez wrote:
>      >    2014-03-21 1:37 GMT-06:00 JC Brand <[1][2]lists@opkode.com>:
>      >
>      >       If you use prebind, then converse cannot reconnect automatically
>      >      because the
>      >      SID and RID it has aren't valid anymore and needs to get new ones
>      (from
>      >      the
>      >      server which prebinds).
>      >
>      >      So I think what needs to happen in the prebind case is that the
>      server
>      >      needs to
>      >      prebind again and supply a new SID and RID to converse.
>      >
>      >    But wouldn't the pre-bind script need the password for this?
> 
>      Yes, but it's something converse doesn't concern itself with. Prebind
>      happens
>      server side.
> 
>    I know, but that would imply storing plain text passwords somewhere,
>    possibly in PHP session, an idea I don't quite like. Otherwise I'd need to
>    ask the user for username/password over and over.

You haven't made it clear whether you are using prebind or not.

If you use prebind, you in any case need to have the user's password server-side.
Whether you have reconnection code or not.

If you aren't using prebind, then converse.js will automatically reconnect,
because it still has the username/pw in memory.

>      >      If the client doesn't quickly enough make another request, the
>      >      connection
>      >      drops.
>      >
>      >    Is converse.js doing this?
> 
>      Javascript is single threaded. If some other expensive operation is
>      holding up
>      the queue, then the next request might not be made quickly enough.
> 
>      Not much converse can do about it except reconnect.
> 
>      I think using websockets should remove these problems (but introduce
>      backward
>      incompatibility with older browsers).
> 
>      Strophe.js (which conversejs uses) now has websocket support, but I
>      haven't
>      tested it or made the necessary modifications required in conversejs in
>      order
>      to use it.
> 
>    I already have certain polling AJAX calls to PHP scripts running every
>    minute or so. Would it help, for instance, sending a ping
>    ([3]http://xmpp.org/extensions/xep-0199.html) with XmppPhp, for example?

They say on the XEP it can be used with BOSH. It might make a difference, I
don't know. It depends on how much you are struggling with disconnections.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-25 @ 20:23
2014-03-24 2:29 GMT-06:00 JC Brand <lists@opkode.com>:

> >      Yes, but it's something converse doesn't concern itself with.
> Prebind
> >      happens
> >      server side.
> >
> >    I know, but that would imply storing plain text passwords somewhere,
> >    possibly in PHP session, an idea I don't quite like. Otherwise I'd
> need to
> >    ask the user for username/password over and over.
>
> You haven't made it clear whether you are using prebind or not.
>


Yes, I'm using prebind, in order to avoid double login. The path is:

converse.js <-> XmppPrebind.php <-> punjab <-> jabberd2

Sorry, I posted this posted in a previous thread, forgot to repost it.


If you use prebind, you in any case need to have the user's password
> server-side.
> Whether you have reconnection code or not.
>


Of course, but they are encrypted in a MySQL database. Since I'm using
PLAIN auth for jabberd2, I'll need to keep the pass in session, as far as I
can figure out :(


>    I already have certain polling AJAX calls to PHP scripts running every
> >    minute or so. Would it help, for instance, sending a ping
> >    ([3]http://xmpp.org/extensions/xep-0199.html) with XmppPhp, for
> example?
>
> They say on the XEP it can be used with BOSH. It might make a difference, I
> don't know. It depends on how much you are struggling with disconnections.
>


Disconnections are as frequent as every minute, or in every page reload.

Thanks.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-26 @ 11:59
On Tue, Mar 25, 2014 at 02:23:49PM -0600, Rodolfo Gonzalez wrote:
>    2014-03-24 2:29 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> 
>      >      Yes, but it's something converse doesn't concern itself with.
>      Prebind
>      >      happens
>      >      server side.
>      >
>      >    I know, but that would imply storing plain text passwords
>      somewhere,
>      >    possibly in PHP session, an idea I don't quite like. Otherwise I'd
>      need to
>      >    ask the user for username/password over and over.
> 
>      You haven't made it clear whether you are using prebind or not.
> 
>    Yes, I'm using prebind, in order to avoid double login. The path is:
>    converse.js <-> XmppPrebind.php <-> punjab <-> jabberd2
>    Sorry, I posted this posted in a previous thread, forgot to repost it.
> 
>      If you use prebind, you in any case need to have the user's password
>      server-side.
>      Whether you have reconnection code or not.
> 
>    Of course, but they are encrypted in a MySQL database. Since I'm using
>    PLAIN auth for jabberd2, I'll need to keep the pass in session, as far as
>    I can figure out :(

 You need the username/pw just before the page is loaded initially, right?
 How do you get it then?

 And then you need it again if converse.js has to reconnect. Just get it the
same way.
> 
>      >    I already have certain polling AJAX calls to PHP scripts running
>      every
>      >    minute or so. Would it help, for instance, sending a ping
>      >    ([3][2]http://xmpp.org/extensions/xep-0199.html) with XmppPhp, for
>      example?
> 
>      They say on the XEP it can be used with BOSH. It might make a
>      difference, I
>      don't know. It depends on how much you are struggling with
>      disconnections.
> 
>    Disconnections are as frequent as every minute, or in every page reload. 
>    Thanks.

That sounds abnormal to me. I don't ever have so many disconnects.

Instead of trying pinging the server, I'd try out websockets if I was you. If
you can drop support for older browsers.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-26 @ 15:56
No, passwords will need to get stored in session, otherwise customers would
need to enter them every minute or so . Session data would be need to be
encrypted and I guess the best place to rebind would be the same place
where the rid update is done. Thanks.

El miércoles, 26 de marzo de 2014, JC Brand <lists@opkode.com> escribió:
> On Tue, Mar 25, 2014 at 02:23:49PM -0600, Rodolfo Gonzalez wrote:
>>    2014-03-24 2:29 GMT-06:00 JC Brand <[1]lists@opkode.com>:
>>
>>      >      Yes, but it's something converse doesn't concern itself with.
>>      Prebind
>>      >      happens
>>      >      server side.
>>      >
>>      >    I know, but that would imply storing plain text passwords
>>      somewhere,
>>      >    possibly in PHP session, an idea I don't quite like. Otherwise
I'd
>>      need to
>>      >    ask the user for username/password over and over.
>>
>>      You haven't made it clear whether you are using prebind or not.
>>
>>    Yes, I'm using prebind, in order to avoid double login. The path is:
>>    converse.js <-> XmppPrebind.php <-> punjab <-> jabberd2
>>    Sorry, I posted this posted in a previous thread, forgot to repost it.
>>
>>      If you use prebind, you in any case need to have the user's password
>>      server-side.
>>      Whether you have reconnection code or not.
>>
>>    Of course, but they are encrypted in a MySQL database. Since I'm using
>>    PLAIN auth for jabberd2, I'll need to keep the pass in session, as
far as
>>    I can figure out :(
>
>  You need the username/pw just before the page is loaded initially, right?
>  How do you get it then?
>
>  And then you need it again if converse.js has to reconnect. Just get it
the
> same way.
>>
>>      >    I already have certain polling AJAX calls to PHP scripts
running
>>      every
>>      >    minute or so. Would it help, for instance, sending a ping
>>      >    ([3][2]http://xmpp.org/extensions/xep-0199.html) with XmppPhp,
for
>>      example?
>>
>>      They say on the XEP it can be used with BOSH. It might make a
>>      difference, I
>>      don't know. It depends on how much you are struggling with
>>      disconnections.
>>
>>    Disconnections are as frequent as every minute, or in every page
reload.
>>    Thanks.
>
> That sounds abnormal to me. I don't ever have so many disconnects.
>
> Instead of trying pinging the server, I'd try out websockets if I was
you. If
> you can drop support for older browsers.
>

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-26 @ 20:26
Hmm, I was thinking: is there any way to attach a callback to some event in
converse.js which would be triggered on reconnect? This way I could call
using AJAX a custom PHP action to reconnect. Thanks.


2014-03-26 9:56 GMT-06:00 Rodolfo Gonzalez <metayii.framework@gmail.com>:

> No, passwords will need to get stored in session, otherwise customers
> would need to enter them every minute or so . Session data would be need to
> be encrypted and I guess the best place to rebind would be the same place
> where the rid update is done. Thanks.
>
> El miércoles, 26 de marzo de 2014, JC Brand <lists@opkode.com> escribió:
>
> > On Tue, Mar 25, 2014 at 02:23:49PM -0600, Rodolfo Gonzalez wrote:
> >>    2014-03-24 2:29 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> >>
> >>      >      Yes, but it's something converse doesn't concern itself
> with.
> >>      Prebind
> >>      >      happens
> >>      >      server side.
> >>      >
> >>      >    I know, but that would imply storing plain text passwords
> >>      somewhere,
> >>      >    possibly in PHP session, an idea I don't quite like.
> Otherwise I'd
> >>      need to
> >>      >    ask the user for username/password over and over.
> >>
> >>      You haven't made it clear whether you are using prebind or not.
> >>
> >>    Yes, I'm using prebind, in order to avoid double login. The path is:
> >>    converse.js <-> XmppPrebind.php <-> punjab <-> jabberd2
> >>    Sorry, I posted this posted in a previous thread, forgot to repost
> it.
> >>
> >>      If you use prebind, you in any case need to have the user's
> password
> >>      server-side.
> >>      Whether you have reconnection code or not.
> >>
> >>    Of course, but they are encrypted in a MySQL database. Since I'm
> using
> >>    PLAIN auth for jabberd2, I'll need to keep the pass in session, as
> far as
> >>    I can figure out :(
> >
> >  You need the username/pw just before the page is loaded initially,
> right?
> >  How do you get it then?
> >
> >  And then you need it again if converse.js has to reconnect. Just get it
> the
> > same way.
> >>
> >>      >    I already have certain polling AJAX calls to PHP scripts
> running
> >>      every
> >>      >    minute or so. Would it help, for instance, sending a ping
> >>      >    ([3][2]http://xmpp.org/extensions/xep-0199.html) with
> XmppPhp, for
> >>      example?
> >>
> >>      They say on the XEP it can be used with BOSH. It might make a
> >>      difference, I
> >>      don't know. It depends on how much you are struggling with
> >>      disconnections.
> >>
> >>    Disconnections are as frequent as every minute, or in every page
> reload.
> >>    Thanks.
> >
> > That sounds abnormal to me. I don't ever have so many disconnects.
> >
> > Instead of trying pinging the server, I'd try out websockets if I was
> you. If
> > you can drop support for older browsers.
> >
>

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-26 @ 21:40
On Wed, Mar 26, 2014 at 02:26:04PM -0600, Rodolfo Gonzalez wrote:
>    Hmm, I was thinking: is there any way to attach a callback to some event
>    in converse.js which would be triggered on reconnect? This way I could
>    call using AJAX a custom PHP action to reconnect. Thanks.

Currently we don't fire an event, but it's a good idea to fire an event when
the client needs to reconnect.

The event needs to be fired here:
https://github.com/jcbrand/converse.js/blob/master/converse.js#L322

Something like:

    converse.emit('onReconnect');

I don't have the time to do this in the coming days, but I'll make a note. In
the meantime, you can do it yourself.

Regards
JC

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-27 @ 04:55
2014-03-26 15:40 GMT-06:00 JC Brand <lists@opkode.com>:

> On Wed, Mar 26, 2014 at 02:26:04PM -0600, Rodolfo Gonzalez wrote:
> >    Hmm, I was thinking: is there any way to attach a callback to some
> event
> >    in converse.js which would be triggered on reconnect? This way I could
> >    call using AJAX a custom PHP action to reconnect. Thanks.
>
> Currently we don't fire an event, but it's a good idea to fire an event
> when
> the client needs to reconnect.
>
> The event needs to be fired here:
> https://github.com/jcbrand/converse.js/blob/master/converse.js#L322
>
> Something like:
>
>     converse.emit('onReconnect');
>
> I don't have the time to do this in the coming days, but I'll make a note.
> In
> the meantime, you can do it yourself.



Ok, this is a very dirty hack, but reconnection seems to be working,
however the prompt is not changed from "reconnecting" to "online contacts".
But, when I load another page, the connection is there:

In convers.js:


        this.reconnect = function () {
            converse.giveFeedback(__('Reconnecting'), 'error');
            if (!converse.prebind) {
                this.connection.connect(
                    this.connection.jid,
                    this.connection.pass,
                    function (status, condition) {
                        converse.onConnect(status, condition, true);
                    },
                    this.connection.wait,
                    this.connection.hold,
                    this.connection.route
                );
            }
            else {
               converse.emit('onReconnect'); // <- modification here
            }
        };


In the PHP page:


converse.on('onReconnect', function() {
   jQuery.ajax({
      'type':'GET',
      'url':'{$urlReconnect}',
      'success':function(data) {
         converse.jid = data.jid;
         converse.sid = data.sid;
         converse.rid = data.rid;
         converse.reconnect();
         converse.onReconnected();
      },
      'error':function(x, h, t) {
         alert('Error: ' + t);
      }
   });
});


Where $urlReconnect is a PHP action which does the BOSH login, and returns
a JSON string with jid, sid and rid.

Comments are appreciated, in order to correct or improve the code.

Thanks.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-27 @ 15:06
2014-03-26 22:55 GMT-06:00 Rodolfo Gonzalez <metayii.framework@gmail.com>:

> 2014-03-26 15:40 GMT-06:00 JC Brand <lists@opkode.com>:
> Currently we don't fire an event, but it's a good idea to fire an event
> when
>
>> the client needs to reconnect.
>>
>> The event needs to be fired here:
>> https://github.com/jcbrand/converse.js/blob/master/converse.js#L322
>>
>> Something like:
>>
>>     converse.emit('onReconnect');
>>
>> I don't have the time to do this in the coming days, but I'll make a
>> note. In
>> the meantime, you can do it yourself.
>
>
>
> Ok, this is a very dirty hack, but reconnection seems to be working,
> however the prompt is not changed from "reconnecting" to "online contacts".
> But, when I load another page, the connection is there:
>
> In the PHP page:
>
> converse.on('onReconnect', function() {
>    jQuery.ajax({
>       'type':'GET',
>       'url':'{$urlReconnect}',
>       'success':function(data) {
>          converse.jid = data.jid;
>          converse.sid = data.sid;
>          converse.rid = data.rid;
>          converse.reconnect();
>          converse.onReconnected();
>       },
>       'error':function(x, h, t) {
>          alert('Error: ' + t);
>       }
>    });
> });
>
>
> Where $urlReconnect is a PHP action which does the BOSH login, and returns
> a JSON string with jid, sid and rid.
>
>

Ok, tested and the code in the success handler didn't work. It seems that
converse.js does not reconnect with the new sid, jid and rid. But I dunno
how can be this done? Thanks.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-04-01 @ 08:05
On Thu, Mar 27, 2014 at 09:06:26AM -0600, Rodolfo Gonzalez wrote:
>    2014-03-26 22:55 GMT-06:00 Rodolfo Gonzalez
>    <[1]metayii.framework@gmail.com>:
> 
>      2014-03-26 15:40 GMT-06:00 JC Brand <[2]lists@opkode.com>:
>      Currently we don't fire an event, but it's a good idea to fire an event
>      when
> 
>        the client needs to reconnect.
> 
>        The event needs to be fired here:
>        [3]https://github.com/jcbrand/converse.js/blob/master/converse.js#L322
> 
>        Something like:
> 
>            converse.emit('onReconnect');
> 
>        I don't have the time to do this in the coming days, but I'll make a
>        note. In
>        the meantime, you can do it yourself.
> 
>      Ok, this is a very dirty hack, but reconnection seems to be working,
>      however the prompt is not changed from "reconnecting" to "online
>      contacts". But, when I load another page, the connection is there:
>      In the PHP page:
>      converse.on('onReconnect', function() {
>         jQuery.ajax({
>            'type':'GET',
>            'url':'{$urlReconnect}',
>            'success':function(data) {
>               converse.jid = data.jid;
>               converse.sid = data.sid;
>               converse.rid = data.rid;
>               converse.reconnect();
>               converse.onReconnected();
>            },
>            'error':function(x, h, t) {
>               alert('Error: ' + t);
>            }
>         });
>      });
>      Where $urlReconnect is a PHP action which does the BOSH login, and
>      returns a JSON string with jid, sid and rid.
> 
>    Ok, tested and the code in the success handler didn't work. It seems that
>    converse.js does not reconnect with the new sid, jid and rid. But I dunno
>    how can be this done? Thanks.

After you've received the new sid, rid and jid, you need to call 
converse.connection.attach:

See here:
    https://github.com/jcbrand/converse.js/blob/master/converse.js#L3534

Try to do this with the existing connection (i.e. don't create a new
Strophe.Connection obj) otherwise all the handlers will be deregistered.

I'm not 100% sure whether reusing the existing connection will work, but I hope
so otherwise it gets more complicated.

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-04-03 @ 20:47
2014-04-01 2:05 GMT-06:00 JC Brand <lists@opkode.com>:

> After you've received the new sid, rid and jid, you need to call
> converse.connection.attach:
>
> See here:
>     https://github.com/jcbrand/converse.js/blob/master/converse.js#L3534
>
> Try to do this with the existing connection (i.e. don't create a new
> Strophe.Connection obj) otherwise all the handlers will be deregistered.
>
> I'm not 100% sure whether reusing the existing connection will work, but I
> hope
> so otherwise it gets more complicated.
>

Thanks JC, now I have this in converse.js:

        this.reconnect = function () {
            converse.giveFeedback(__('Reconnecting'), 'error');
            if (!converse.prebind) {
                this.connection.connect(
                    this.connection.jid,
                    this.connection.pass,
                    function (status, condition) {
                        converse.onConnect(status, condition, true);
                    },
                    this.connection.wait,
                    this.connection.hold,
                    this.connection.route
                );
            }
            else {
               converse.emit('onReconnect'); // this is new
            }
        };

        // this goes near the botton of the converse.js code:

        'reconnect': function(jid, sid, rid) {
           converse.connection.attach(jid, sid, rid, converse.onConnect);
        },

And in the page:

converse.on('onReconnect', function(o) {
   jQuery.ajax({
      'type':'GET',
      'cache':false,
      'dataType':'json',
      'url':'{$urlReconnect}',
      'success':function(data) {
         converse.reconnect(data.jid, data.sid, data.rid);
      },
      'error':function(x, h, t) {
         alert('Error: ' + t);
      }
   });
});

It seems to be working fine on reconnections, since while connected with
Exodus with another account, I see the converse.js user connected. The
problem I have now is that the converse.js contact list is not being
refreshed, so contacts appear offline.

I guess there's some function to refresh the list. Looking for it :)

Thanks.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-04-05 @ 07:51
On Thu, Apr 03, 2014 at 02:47:04PM -0600, Rodolfo Gonzalez wrote:
>    2014-04-01 2:05 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> 
>      After you've received the new sid, rid and jid, you need to call
>      converse.connection.attach:
>      See here:
>         
>      [2]https://github.com/jcbrand/converse.js/blob/master/converse.js#L3534
> 
>      Try to do this with the existing connection (i.e. don't create a new
>      Strophe.Connection obj) otherwise all the handlers will be deregistered.
> 
>      I'm not 100% sure whether reusing the existing connection will work, but
>      I hope
>      so otherwise it gets more complicated.
> 
>    Thanks JC, now I have this in converse.js:
>            this.reconnect = function () {
>                converse.giveFeedback(__('Reconnecting'), 'error');
>                if (!converse.prebind) {
>                    this.connection.connect(
>                        this.connection.jid,
>                        this.connection.pass,
>                        function (status, condition) {
>                            converse.onConnect(status, condition, true);
>                        },
>                        this.connection.wait,
>                        this.connection.hold,
>                        this.connection.route
>                    );
>                }
>                else {
>                   converse.emit('onReconnect'); // this is new
>                }
>            };
>            // this goes near the botton of the converse.js code:
>            'reconnect': function(jid, sid, rid) {
>               converse.connection.attach(jid, sid, rid, converse.onConnect);
>            },
>    And in the page:
>    converse.on('onReconnect', function(o) {
>       jQuery.ajax({
>          'type':'GET',
>          'cache':false,
>          'dataType':'json',
>          'url':'{$urlReconnect}',
>          'success':function(data) {
>             converse.reconnect(data.jid, data.sid, data.rid);
>          },
>          'error':function(x, h, t) {
>             alert('Error: ' + t);
>          }
>       });
>    });
>    It seems to be working fine on reconnections, since while connected with
>    Exodus with another account, I see the converse.js user connected. The
>    problem I have now is that the converse.js contact list is not being
>    refreshed, so contacts appear offline.
>    I guess there's some function to refresh the list. Looking for it :) 
 
Good! You're doing research for the rest of us ;)

When you manually change a roster contact's status, does the roster update?

The thing is, the "converse.onConnect" method that you pass in as callback
should already refresh the roster.

I'm referring to this:

>            // this goes near the botton of the converse.js code:
>            'reconnect': function(jid, sid, rid) {
>               converse.connection.attach(jid, sid, rid, converse.onConnect);
>            },

The line where the roster is refreshed is here:
https://github.com/jcbrand/converse.js/blob/master/converse.js#L532

Check whether it actually gets called after you've reconnected.

Regards
JC

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-04-07 @ 03:36
2014-04-05 1:51 GMT-06:00 JC Brand <lists@opkode.com>:

> On Thu, Apr 03, 2014 at 02:47:04PM -0600, Rodolfo Gonzalez wrote:
> >    2014-04-01 2:05 GMT-06:00 JC Brand <[1]lists@opkode.com>:
> >    It seems to be working fine on reconnections, since while connected
> with
> >    Exodus with another account, I see the converse.js user connected. The
> >    problem I have now is that the converse.js contact list is not being
> >    refreshed, so contacts appear offline.
> >    I guess there's some function to refresh the list. Looking for it :)
>
> Good! You're doing research for the rest of us ;)
>
> When you manually change a roster contact's status, does the roster update?
>
>

No, it does not. I even disconnected and connected again in Exodus, and the
contact remained the same (disconnected) in converse.js.



> The thing is, the "converse.onConnect" method that you pass in as callback
> should already refresh the roster.
>


Yes, I found it out.



> I'm referring to this:
>
> >            // this goes near the botton of the converse.js code:
> >            'reconnect': function(jid, sid, rid) {
> >               converse.connection.attach(jid, sid, rid,
> converse.onConnect);
> >            },
>
> The line where the roster is refreshed is here:
> https://github.com/jcbrand/converse.js/blob/master/converse.js#L532
>
> Check whether it actually gets called after you've reconnected.
>


Checked: the code this.connection.roster.get(function () {}); is executed
but nothing changes.

I'm not sure if I should be doing this:

converse.connection.attach(jid, sid, rid, converse.onConnect);

on "converse". Is this right?

Regards.

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-04-10 @ 06:53
On Sun, Apr 06, 2014 at 10:36:04PM -0500, Rodolfo Gonzalez wrote:

<snip>

>    Checked: the code this.connection.roster.get(function () {}); is executed
>    but nothing changes.
>    I'm not sure if I should be doing this:
>    converse.connection.attach(jid, sid, rid, converse.onConnect);
>    on "converse". Is this right?

Looks right.

Can you send messages to other users? In other words, are you sure that the
connection is properly set up after re-attaching?

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-04-11 @ 02:58
2014-04-10 1:53 GMT-05:00 JC Brand <lists@opkode.com>:

> On Sun, Apr 06, 2014 at 10:36:04PM -0500, Rodolfo Gonzalez wrote:
>
> >    Checked: the code this.connection.roster.get(function () {}); is
> executed
> >    but nothing changes.
> >    I'm not sure if I should be doing this:
> >    converse.connection.attach(jid, sid, rid, converse.onConnect);
> >    on "converse". Is this right?
>
> Looks right.
>
> Can you send messages to other users? In other words, are you sure that the
> connection is properly set up after re-attaching?
>


I can send messages to another user while being marked offline in that
user's roster. The user receives the message correctly, and he can answer
it. But the presence part seems not to be working. I'm stuck on that.

Re: [conversejs] Prebind session and reconnect

From:
Alexandre Coloma
Date:
2014-04-11 @ 06:13
I have the same issue to.
Alex


2014-04-11 4:58 GMT+02:00 Rodolfo Gonzalez <metayii.framework@gmail.com>:

> 2014-04-10 1:53 GMT-05:00 JC Brand <lists@opkode.com>:
>
>> On Sun, Apr 06, 2014 at 10:36:04PM -0500, Rodolfo Gonzalez wrote:
>>
>> >    Checked: the code this.connection.roster.get(function () {}); is
>> executed
>> >    but nothing changes.
>> >    I'm not sure if I should be doing this:
>> >    converse.connection.attach(jid, sid, rid, converse.onConnect);
>> >    on "converse". Is this right?
>>
>> Looks right.
>>
>> Can you send messages to other users? In other words, are you sure that
>> the
>> connection is properly set up after re-attaching?
>>
>
>
> I can send messages to another user while being marked offline in that
> user's roster. The user receives the message correctly, and he can answer
> it. But the presence part seems not to be working. I'm stuck on that.
>

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-04-14 @ 08:42
On Fri, Apr 11, 2014 at 08:13:43AM +0200, Alexandre Coloma wrote:
>    I have the same issue to.
>    Alex
> 
>    2014-04-11 4:58 GMT+02:00 Rodolfo Gonzalez
>    <[1]metayii.framework@gmail.com>:
> 
>      2014-04-10 1:53 GMT-05:00 JC Brand <[2]lists@opkode.com>:
> 
>        On Sun, Apr 06, 2014 at 10:36:04PM -0500, Rodolfo Gonzalez wrote:
> 
>        >    Checked: the code this.connection.roster.get(function () {}); is
>        executed
>        >    but nothing changes.
>        >    I'm not sure if I should be doing this:
>        >    converse.connection.attach(jid, sid, rid, converse.onConnect);
>        >    on "converse". Is this right?
> 
>        Looks right.
> 
>        Can you send messages to other users? In other words, are you sure
>        that the
>        connection is properly set up after re-attaching?
> 
>      I can send messages to another user while being marked offline in that
>      user's roster. The user receives the message correctly, and he can
>      answer it. But the presence part seems not to be working. I'm stuck on
>      that.

This is now after automatically reconnecting?

Check these two places in the code, and see if they ever get called after
reconnection:

* presenceHandler: 
https://github.com/jcbrand/converse.js/blob/master/converse.js#L2915 
* rosterHandler: 
https://github.com/jcbrand/converse.js/blob/master/converse.js#L2813

Re: [conversejs] Prebind session and reconnect

From:
Jc Brand
Date:
2014-03-26 @ 21:34
On Wed, Mar 26, 2014 at 09:56:55AM -0600, Rodolfo Gonzalez wrote:
>    No, passwords will need to get stored in session, otherwise customers
>    would need to enter them every minute or so . Session data would be need
>    to be encrypted and I guess the best place to rebind would be the same
>    place where the rid update is done. Thanks.

There's something that doesn't make sense to me here.

In my prebind case: on my server, I authenticate via BOSH with the XMPP server,
before every page load. I then pass the RID and SID values to converse.js.

How do you do it? Do users give their passwords when they visit the site, and
then with each new page load (once they are logged in), you manually just bump
the RID and keep the same SID? How do you get your RID and SID values for each
new page that loads?

Re: [conversejs] Prebind session and reconnect

From:
Rodolfo Gonzalez
Date:
2014-03-26 @ 21:52
2014-03-26 15:34 GMT-06:00 JC Brand <lists@opkode.com>:

> On Wed, Mar 26, 2014 at 09:56:55AM -0600, Rodolfo Gonzalez wrote:
> >    No, passwords will need to get stored in session, otherwise customers
> >    would need to enter them every minute or so . Session data would be
> need
> >    to be encrypted and I guess the best place to rebind would be the same
> >    place where the rid update is done. Thanks.
>
> There's something that doesn't make sense to me here.
>
> In my prebind case: on my server, I authenticate via BOSH with the XMPP
> server,
> before every page load. I then pass the RID and SID values to converse.js.
>
> How do you do it? Do users give their passwords when they visit the site,
> and
> then with each new page load (once they are logged in), you manually just
> bump
> the RID and keep the same SID? How do you get your RID and SID values for
> each
> new page that loads?
>


I'm trying to integrate converse.js into a home grown CMS. Users enter the
login and password in the login page, and in the same action which
authenticates the user in the CMS, I authenticate him via BOSH, but just
once, in that action. Then I have a PHP action which is executed by
converse.js in every page load, which just increases the RID by one, but
does not authenticate the user again.

This is the login code, executed just once, when the user enters the CMS:


if (isset(Yii::app()->params['XMPP']['SERVER'])) {
   try {
      include_once('lib/bind/XmppPrebind.php');
      $server = Yii::app()->params['XMPP']['SERVER'];
      $port   = Yii::app()->params['XMPP']['PORT'];
      $xmppPrebind = new XmppPrebind($server,
"http://{$server}:{$port}/http-bind",
Yii::app()->id, false, false);
      $xmppPrebind->connect($model->username, $model->password);
      $xmppPrebind->auth();
      $sessionInfo = $xmppPrebind->getSessionInfo(); // array containing
sid, rid and jid
      if (is_array($sessionInfo)) {
        $sessionInfo['bosh_service_url'] = "http://
{$server}:{$port}/http-bind";
        Yii::app()->user->setState('sessionInfo', $sessionInfo); //
sessionInfo is persisted in $_SESSION
      }
   }
   catch (Exception $e) {
       Yii::app()->qa->catchException($e, get_class($this));
   }
}


This is the converse.js init code, in every page:


      $lang = Yii::app()->language;
      $urlBosh = Yii::app()->createUrl('/messenger');
      $script =<<<END
jQuery.getJSON('{$urlBosh}', function(data) {
   converse.initialize({
      allow_otr: false,
      auto_list_rooms: false,
      auto_subscribe: false,
      show_controlbox_by_default: false,
      hide_muc_server: true,
      xhr_user_search: false,
      debug: true,
      i18n: locales['{$lang}'],
      prebind: true,
      bosh_service_url: data.bosh_service_url,
      jid: data.jid,
      sid: data.sid,
      rid: data.rid
   });
});
END;


And this is the messenger action code, where just the RID is increased (no
further auth is done):


public function actionIndex()
{
      try {
         $boshSessionInfo = Yii::app()->user->getState('sessionInfo', null);
         if ($boshSessionInfo !== null) {
            $boshSessionInfo['rid'] = $boshSessionInfo['rid'] + 1;
            Yii::app()->user->setState('sessionInfo', $boshSessionInfo);

            echo CJSON::encode($boshSessionInfo);

            Yii::app()->end();
         }
      }
catch (Exception $e) {
         Yii::app()->catchException($e, get_class($this));
      }
}


Otherwise I'd need to place the auth code also in my actionIndex method, so
a new session is opened everytime.