connection.isRetrying not working for me (sort of)

#1

I have the javascript code:

var connection = new autobahn.Connection({

url: ‘%s’,

realm: ‘%s’

});

connection.onclose = function (session) {

console.log(‘Session to database closed’);

if(connection.isRetrying == true) {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (retrying)

’;

} else {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (forever)

’;

};

};

I tried to debug this for a while. I was just killing the router, which triggered the onclose. The problem I was seeing was my javascript was picking up connection.isRetrying == false.

It appears that when the connection first goes down, isRetrying is false. Then, after the first retry, isRetrying is true. What is the proper way to determine if my connection will be retried?

-g

0 Likes

#2

Hi Greg,

try:

connection.onclose = function (details) {
console.log(details.will_retry);
}

You can also (manually) stop automatic retrying by returning true from above handler.

Cheers,
/Tobias

···

Am Freitag, 21. November 2014 14:43:37 UTC+1 schrieb Greg Fausak:

I have the javascript code:

var connection = new autobahn.Connection({

url: ‘%s’,

realm: ‘%s’

});

connection.onclose = function (session) {

console.log(‘Session to database closed’);

if(connection.isRetrying == true) {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (retrying)

’;

} else {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (forever)

’;

};

};

I tried to debug this for a while. I was just killing the router, which triggered the onclose. The problem I was seeing was my javascript was picking up connection.isRetrying == false.

It appears that when the connection first goes down, isRetrying is false. Then, after the first retry, isRetrying is true. What is the proper way to determine if my connection will be retried?

-g

0 Likes

#3

Tobias,

I tried the following code:

connection.onclose = function (details) {

console.log('will_retry ', details.will_retry);

Here is the console log for that message:

will_retry undefined

Maybe my autobahn.min.js file is old?

-g

···

On Friday, November 21, 2014 3:32:59 PM UTC-6, Tobias Oberstein wrote:

I have the javascript code:

var connection = new autobahn.Connection({

url: ‘%s’,

realm: ‘%s’

});

connection.onclose = function (session) {

console.log(‘Session to database closed’);

if(connection.isRetrying == true) {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (retrying)

’;

} else {

document.getElementById(“info”).innerHTML = ‘

Autobahn Connection Closed (forever)

’;

};

};

I tried to debug this for a while. I was just killing the router, which triggered the onclose. The problem I was seeing was my javascript was picking up connection.isRetrying == false.

It appears that when the connection first goes down, isRetrying is false. Then, after the first retry, isRetrying is true. What is the proper way to determine if my connection will be retried?

-g

Hi Greg,

try:

connection.onclose = function (details) {
console.log(details.will_retry);
}

You can also (manually) stop automatic retrying by returning true from above handler.

Cheers,
/Tobias

Am Freitag, 21. November 2014 14:43:37 UTC+1 schrieb Greg Fausak:

0 Likes

#4

I get ‘true’, with version 0.9.5.

0 Likes

#5

That’s weird.

When I just log the value of ‘details’ I get ‘lost’, like details is just a string.

The source …

     // fire app code handler
     //
     if (self.onclose) {
        var details = {
           reason: self._session_close_reason,
           message: self._session_close_message,
           retry_delay: next_retry.delay,
           retry_count: next_retry.count,
           will_retry: next_retry.will_retry
        };
        try {
           // Connection.onclose() allows to cancel any subsequent retry attempt
           var stop_retrying = self.onclose(reason, details);
        } catch (e) {
           log.debug("Exception raised from app code while firing Connection.onclose()", e);
        }
     }

So I had the function declared with one argument(details) instead of two (reason,details).

-g

···

On Sunday, November 23, 2014 8:48:25 AM UTC-6, Greg Miller wrote:

I get ‘true’, with version 0.9.5.

0 Likes

#6

I just have:

connection.onclose = function (reason, details) {
console.log(details.will_retry)
console.log("Connection lost: " + reason);
}

``

0 Likes

#7

that’s what it was, my code:

connection.onclose = function (details) {

console.log('will_retry ', details.will_retry);

did not declare the first argument.

thx,

-g

···

On Sun, Nov 23, 2014 at 10:28 AM, Greg Miller roam3...@gmail.com wrote:

I just have:

connection.onclose = function (reason, details) {
console.log(details.will_retry)
console.log("Connection lost: " + reason);
}

``

You received this message because you are subscribed to a topic in the Google Groups “Autobahn” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/autobahnws/HLTL9jzXENE/unsubscribe.

To unsubscribe from this group and all its topics, send an email to autobahnws+...@googlegroups.com.

To post to this group, send email to autob...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/e260c81a-af6e-458c-833a-abf91939e051%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Greg Fausak
lgfa...@gmail.com

0 Likes