How to check failure in the subscription

24 views
Skip to first unread message

Matteo Sani

unread,
May 24, 2018, 9:42:37 AM5/24/18
to Crossbar
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.

Adam Jorgensen

unread,
May 25, 2018, 3:28:32 AM5/25/18
to Crossbar
Hi Matteo


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

Matteo Sani

unread,
May 28, 2018, 4:10:43 AM5/28/18
to cross...@googlegroups.com
Hi Adam, 
thank you very much for your prompt and clear answer.

Cheers, 
Matteo.

--
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.
Reply all
Reply to author
Forward
0 new messages