Question on loss of connection and Promisies

#1

I’d like to know what happens to any pending Promises *(in the Javascript client) *when a Websocket connection is lost/disconnected?

Along similar lines is there any mechanism to fail a Promise if an RPC response isn’t received within a certain time frame.

I am currently using Now.js in an app I’m developing and looking at alternatives as Now.js is no longer being developed or supported and I suspect I am having an issue with it. Autobahn looks like a good fit, with good docs and a well thought through set of capabilities.

0 Likes

#2

I'd like to know what happens to any pending Promises /(in the
Javascript client) /when a Websocket connection is lost/disconnected?

Currently, with AutobahnJS, those promises will never fire. For single page apps that do all their communication via WAMP/WebSocket, the loss of connection is likely fatal, and the connection loss is signaled on the session object.

Sure, we could reject all outstanding promises automatically, but in what order? Any deterministic order will require some book keeping.
Or we could provide a list of outstanding promises in the connection lost event and an app can then do what it wants with the promises.

I'm not sure if above would be of practical value .. but I'm not dogmatic about that. If it helps, we can add s.th. (modulo expensive bookkeeping)

Along similar lines is there any mechanism to fail a Promise if an RPC
response isn't received within a certain time frame.

Now we are talking about the situation when the connection is not lost, but no RPC response is received within some time, right?

I can see 3 variants:

1. timeout/reject the promise client-side without telling the server, and should the server respond later, silently ignore the response (which might be a success or error response)

2. timeout/reject the promise client-side and actively cancel the call

3. call server with timeout communicated. timeout call execution on server-side, and return error ("call timeout")

···

Am 19.06.2013 23:30, schrieb Neville Franks:

==

2+3 will be possible with WAMPv2 .. it requires changes to the wire protocol.

https://github.com/tavendo/wamp/blob/master/WAMPv2.md

1. could be done in AutobahnJS without changes to protocol or server

I am currently using Now.js in an app I'm developing and looking at
alternatives as Now.js is no longer being developed or supported and I
suspect I am having an issue with it. Autobahn looks like a good fit,
with good docs and a well thought through set of capabilities.

Thanks! Yep, WAMP (and Autobahn) is gaining traction .. we deliberately kept the core simple, and the RPC+PubSub has proven to be quite capable.

Now that we've gained real-world, practical experience, a couple of areas will get even more powerful with WAMPv2.

/Tobias

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#3

Hi Tobias,

Thanks for the prompt and detailed response.

I don’t have any specific thoughts on what should happen to pending promises on loss of connection and I do appreciate the issues you raised. A follow up question is what happens to pending promises if/when the connection is reestablished, if anything. Maybe this issue is handled best by my second question re. timeouts.

For your comment on loss of connection being fatal for single page apps, I don’t think this is necessarily the case. For my app, most loss of connection cases can be handled gracefully without the user being aware , as long as the loss is short-lived of course.

Re. my timeout question. I think your point 1 offers the most flexibility and lets the client have full control, without involving the server. If the promise completes after the timeout it could still accept the result if it wanted to. This solution could also handle my loss of connection issue as it doesn’t involve the server. And as you say doesn’t involve any wire/server changes. So this is something I’d see as being a very useful enhancement.

One nice capability of Now.js is that the server can initiate an RPC call to client(s). I don’t see that Autobahn provides this, however from my reading the server can Publish to clients so that will satisfy my need here.

Keep up the great work. I look forward to using Autobahn in the near future.

···

On Thursday, 20 June 2013 07:30:17 UTC+10, Neville Franks wrote:

I’d like to know what happens to any pending Promises *(in the Javascript client) *when a Websocket connection is lost/disconnected?

Along similar lines is there any mechanism to fail a Promise if an RPC response isn’t received within a certain time frame.

I am currently using Now.js in an app I’m developing and looking at alternatives as Now.js is no longer being developed or supported and I suspect I am having an issue with it. Autobahn looks like a good fit, with good docs and a well thought through set of capabilities.

0 Likes

#4

Hi Neville,

Hi Tobias,
Thanks for the prompt and detailed response.

I don't have any specific thoughts on what should happen to pending
promises on loss of connection and I do appreciate the issues you
raised. A follow up question is what happens to pending promises if/when
the connection is reestablished, if anything. Maybe this issue is
handled best by my second question re. timeouts.

For your comment on loss of connection being fatal for single page apps,
I don't think this is necessarily the case. For my app, most loss of
connection cases can be handled gracefully without the user being aware
, as long as the loss is short-lived of course.

Re. my timeout question. I think your point 1 offers the most
flexibility and lets the client have full control, without involving the
server. If the promise completes after the timeout it could still accept

I've added issues for those potential enhancements:

https://github.com/tavendo/AutobahnJS/issues/24
https://github.com/tavendo/AutobahnJS/issues/26
https://github.com/tavendo/AutobahnJS/issues/27

the result if it wanted to. This solution could also handle my loss of

Note that once the promise has been rejected, there is no way of providing a result that later arrives to the app. It'll be just silently ignored.

connection issue as it doesn't involve the server. And as you say
doesn't involve any wire/server changes. So this is something I'd see as
being a very useful enhancement.

One nice capability of Now.js is that the server can initiate an RPC
call to client(s). I don't see that Autobahn provides this, however from

AutobahnPython already provides this: symmetric RPC
https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/rpc/symmetric

It's not yet implemented in AutobahnJS
https://github.com/tavendo/AutobahnJS/issues/25

my reading the server can Publish to clients so that will satisfy my
need here.

Keep up the great work. I look forward to using Autobahn in the near future.

Great that it works for your needs!

/Tobias

···

Am 20.06.2013 01:28, schrieb Neville Franks:

On Thursday, 20 June 2013 07:30:17 UTC+10, Neville Franks wrote:

    I'd like to know what happens to any pending Promises /(in the
    Javascript client) /when a Websocket connection is lost/disconnected?

    Along similar lines is there any mechanism to fail a Promise if an
    RPC response isn't received within a certain time frame.

    I am currently using Now.js in an app I'm developing and looking at
    alternatives as Now.js is no longer being developed or supported and
    I suspect I am having an issue with it. Autobahn looks like a good
    fit, with good docs and a well thought through set of capabilities.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes