How to check failure in the subscription

#1

Hi experts,

I am quite new to crossbar so forgive me for the naive question. I have recently noticed a misbehaviour of my application which crossbar-wise is quite simple:

  1. at the beginning I subscribe to many topics at once

  2. as soon as one of the topic is updated, I perform some calculation based on the number I received.

  3. independently (in a second application) the same topics are subscribed in order store them in a DB.

Unfortunately I have discovered that sometimes my first app, the one that does the calculations, doesn’t receive the updates (I checked that the publication of the updated values is succesful looking at the values stored in the DB by the second app). Looking at the code I started wondering if something may be wrong with the subscription to the topic.

So here my two questions:

  • first of all is it reasonable to assume that sometimes a subscription may fail ? (it seems to me such a simple operation that I am not sure how it could fail)

  • which is the Deferred value returned by the “subscribe” statement in case of a failure ?

Below few lines of code I wrote for testing where I am not sure if it is enough to check result.active to say the subscription was OK:

def printData(self, result):

if (result.active):

print (“Subscription OK”)

else:

print (“Subscription failed”)

def eventLoop(self):

for t in topics:

mysubs = self.subscribe(handler, t, options=SubscribeOprions(details_arg=“details”))

mysub.addCallback(self.printData)

Thank you in advance.

Best regards,

Matteo.

0 Likes

#2

Hi Matteo

Please see the documentation for https://autobahn.readthedocs.io/en/latest/reference/autobahn.wamp.html#autobahn.wamp.interfaces.ISession.subscribe

In the event the subscription fails the Deferred/Future generated by subscribe will reject. I think this means that your printData function will not execute as you added it as a callback on success rather than as an errback.

Cheers

Adam

0 Likes

#3

Hi Adam,
thank you very much for your prompt and clear answer.

Cheers,

Matteo.

···

On Fri, May 25, 2018 at 9:28 AM Adam Jorgensen adam.jor...@gmail.com wrote:

Hi Matteo

Please see the documentation for https://autobahn.readthedocs.io/en/latest/reference/autobahn.wamp.html#autobahn.wamp.interfaces.ISession.subscribe

In the event the subscription fails the Deferred/Future generated by subscribe will reject. I think this means that your printData function will not execute as you added it as a callback on success rather than as an errback.

Cheers

Adam

You received this message because you are subscribed to the Google Groups “Crossbar” group.

To unsubscribe from this group and stop receiving emails from it, send an email to crossbario+...@googlegroups.com.

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

To view this discussion on the web visit https://groups.google.com/d/msgid/crossbario/a91efc10-df10-4c87-8c4d-a7fe7be9b2a3%40googlegroups.com.

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

0 Likes