Wamp ApplicationSession without ApplicationRunner and existing asyncio loop ?

111 views
Skip to first unread message

Freddy

unread,
Nov 25, 2016, 5:44:23 AM11/25/16
to Autobahn
Hi,

I've been stuck for weeks on this problem which might have a very simple solution.

I have an existing asyncio application which takes care of running the asyncio event loop. I would like to optionally plug in a WAMP component what would publish some messages when something happens in my application.

I've been playing around and I'm struggling a lot to understand how to obtain an ApplicationSession instance without the help of the ApplicationRunner class. The reason I don't want to use ApplicationRunner is that the WAMP feature of publishing events has to be optional, and my event loop still needs to run without any WAMP component.

The run() method of ApplicationRunner looks like a good start to take ideas from. But It's not very clear to me what I'm supposed to do. Even if I manage to connect it with WampWebSocketClientFactory, how would my external application interact with it ? What would be a correct entry point from the outside to access the "publish()" feature ?

Maybe I'm having the wrong approach, my final need is simply to be able to optionally publish WAMP messages when something happens in my asyncio application.

Any clue would be very appreciated :)

Freddy

unread,
Nov 30, 2016, 6:35:22 AM11/30/16
to Autobahn
I've done some experimentations and came up with this : https://github.com/ekryyn/rabbitmq-to-wamp/blob/master/mq-client/wamp.py

I'm not sure it's the right approach though... It's also trying to reconnect to the router when it lost the connection. So maybe it will help someone.

For now, I'll go with this approach, maybe I'll find something better.

David Ford

unread,
Dec 6, 2016, 12:54:10 AM12/6/16
to Autobahn
i have an app that i believe does what you're intending to do above. mine is done in py3 and is pure wamp, no rabbitmq needed. i realize this is a week later, let me know and i'll put the code up

--
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.
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/5bcc7743-ccfb-4c90-bdf3-e3926341b144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh M

unread,
Jan 19, 2017, 12:46:01 AM1/19/17
to Autobahn
I just commented on an older post from Freddy from a few months back (that I found via Google Search), so ignore that other post.

David, I'm very interested in your code. We're not using any messaging currently (a monolithic app), so the pure WAMP and no RabbitMQ would be useful indeed.

Thanks,
Josh

David Ford

unread,
Jan 19, 2017, 6:24:46 PM1/19/17
to Autobahn
hey josh, this ought to get you started. https://gist.github.com/FirefighterBlu3/d3fd3f51fcc8d7ba9c24cbe06d22cabf

i use it sort of like a syslog function in a variety of programs. here's the general idea of it:

    import wampcams as wc
    def main():
        _cams = wc.WampClient()
        _cams.publish('blam v%s startup' %(__version__), channel='hive.alerts.blam')

the wamp client runs in its own thread and uses Queue to pass objects around safely with any other thread
-d


--
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.
To post to this group, send email to autob...@googlegroups.com.

Josh M

unread,
Jan 19, 2017, 6:40:22 PM1/19/17
to Autobahn
Very much appreciated, thanks David.

I'll work something out based on your contribution and Freddy's and post back when I do. Mine's a little different: based on Twisted and wanting to add an addition WAMP message to our existing internal Events, so it might be helpful to someone.

David Ford

unread,
Jan 19, 2017, 7:18:26 PM1/19/17
to Autobahn
my pleasure. it should be pretty easy.  iirc, i think Tobias(?) was planning on including a twisted-native reconnecting client to the existing/replaced ApplicationRunner so that leaves you with only the need to ensure your WAMP connection runs freely on its own thread.

p.s. i forgot the _cams.shutdown() above which tries to ensure all messages that were _just_ published get through to the router

-d

--
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.
To post to this group, send email to autob...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages