Getting the current number of publishers and subscribers

56 views
Skip to first unread message

Justin Albano

unread,
Sep 2, 2014, 3:58:42 PM9/2/14
to autob...@googlegroups.com
Hey all,

I'm using Autobahn with Crossbar.io and I wanted to know if there is a way to obtain the current number of publishers and subscribers registered. For example, if a set of publishers and subscribers get registered, how can I poll the system to find the number of publishers and subscribers at the time of the query?

Thank you for your help.




Justin

Tobias Oberstein

unread,
Sep 2, 2014, 4:24:16 PM9/2/14
to autob...@googlegroups.com
Hi Justin,

> I'm using Autobahn with Crossbar.io and I wanted to know if there is a
> way to obtain the current number of publishers and subscribers
> registered. For example, if a set of publishers and subscribers get
> registered, how can I poll the system to find the number of publishers
> and subscribers at the time of the query?

Publishers aren't "registered" in any way. Consequently, there cannot be
an API for listing them.

Subscribers are known to the Router of course. And the way Routers may
expose that is via a meta API:

https://github.com/tavendo/WAMP/blob/master/spec/advanced.md#subscriber-list

These features are part of the "advanced profile" of WAMP, are not yet
fully specified, and not implemented (in Crossbar).

/Tobias

>
> Thank you for your help.
>
>
>
>
> Justin
>
> --
> 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
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/9024a395-9575-4468-be57-dbe095e6cf5a%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/9024a395-9575-4468-be57-dbe095e6cf5a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Justin Albano

unread,
Sep 8, 2014, 2:09:43 PM9/8/14
to autob...@googlegroups.com
Thank you for your help.

Is there a way to access this data through the router (is there some interface to the router that exposes this information currently), or is this information strictly internal to the router?



Justin

Greg Fausak

unread,
Sep 8, 2014, 6:20:40 PM9/8/14
to autob...@googlegroups.com
You might be able to access the data, but, I think it would be internal to Autobahn.  Something you might consider is intercepting the authorize() method in the Router.   I modified mine like this (in basicrouter.py):

class MyRouter(Router):

   def authorize(self, session, uri, action):
      print("MyRouter.authorize: {} {} {}".format(uri, IRouter.ACTION_TO_STRING[action]))

      return True

The messages I see printed out look like this:
2014-09-08 16:57:25-0500 [WampWebSocketServerProtocol,0,192.168.200.230] MyRouter.authorize: peter 1172178439154025 com.timeservice.now register
2014-09-08 16:58:24-0500 [WampWebSocketServerProtocol,1,127.0.0.1] MyRouter.authorize: db 501145212243207 com.db.start register
2014-09-08 16:58:24-0500 [WampWebSocketServerProtocol,1,127.0.0.1] MyRouter.authorize: db 501145212243207 com.db.stop register
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,2,127.0.0.1] MyRouter.authorize: db 8772661627859300 com.db.start call
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,1,127.0.0.1] MyRouter.authorize: db 501145212243207 adm.db.connect register
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,1,127.0.0.1] MyRouter.authorize: db 501145212243207 adm.db.disconnect register
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,1,127.0.0.1] MyRouter.authorize: db 501145212243207 adm.db.query register
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,2,127.0.0.1] MyRouter.authorize: db 8772661627859300 adm.db.connect call
2014-09-08 16:58:30-0500 [WampWebSocketServerProtocol,2,127.0.0.1] MyRouter.authorize: db 8772661627859300 adm.session.list call
2014-09-08 17:16:00-0500 [WampWebSocketServerProtocol,4,127.0.0.1] MyRouter.authorize: peter 5553121740255734 com.myapp.topic1 subscribe
2014-09-08 17:17:26-0500 [WampWebSocketServerProtocol,5,127.0.0.1] MyRouter.authorize: peter 2793087355300538 com.myapp.topic1 publish


The call/register are for rpc.  Using this technique you could create a class that stores the active subscriptions and publishes and create an rpc call to return the list.

I did run into an issue, though.  This is used for authorization. so i guess it already knows if a publish can get to any listeners.  I found that if I did a publish without any subscribers the method was never called to authorize the publish.  That's weird.

-g

Tobias Oberstein

unread,
Sep 11, 2014, 4:28:44 AM9/11/14
to autob...@googlegroups.com
Am 08.09.2014 20:09, schrieb Justin Albano:
> Thank you for your help.
>
> Is there a way to access this data through the router (is there some
> interface to the router that exposes this information currently), or is
> this information strictly internal to the router?

As said, the information does not exist ("list of publishers") or is
exposed via meta API (if implemented by the router).


>
>
>
> Justin
>
>
> On Tuesday, September 2, 2014 3:58:42 PM UTC-4, Justin Albano wrote:
>
> Hey all,
>
> I'm using Autobahn with Crossbar.io and I wanted to know if there is
> a way to obtain the current number of publishers and subscribers
> registered. For example, if a set of publishers and subscribers get
> registered, how can I poll the system to find the number of
> publishers and subscribers at the time of the query?
>
> Thank you for your help.
>
>
>
>
> Justin
>
> --
> 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
> <mailto:autobahnws+...@googlegroups.com>.
> To post to this group, send email to autob...@googlegroups.com
> <mailto:autob...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autobahnws/a5b230b8-c8f3-4d0f-a736-430ff14828fb%40googlegroups.com
> <https://groups.google.com/d/msgid/autobahnws/a5b230b8-c8f3-4d0f-a736-430ff14828fb%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages