Wamp ApplicationSession without ApplicationRunner and existing asyncio loop ?

#1

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 :slight_smile:

0 Likes

#2

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.

···

On Friday, 25 November 2016 10:44:23 UTC, Freddy wrote:

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 :slight_smile:

0 Likes

#3

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

···

On Wed, Nov 30, 2016 at 6:35 AM Freddy tede...@gmail.com wrote:

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.

On Friday, 25 November 2016 10:44:23 UTC, Freddy wrote:

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 :slight_smile:

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.

0 Likes

#4

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

0 Likes

#5

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

···

On Thu, Jan 19, 2017 at 12:46 AM Josh M josh.m...@tecevo.com wrote:

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

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/5354932c-ad2e-4966-a61b-0a3d3e923404%40googlegroups.com.

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

0 Likes

#6

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.

···

On Friday, 20 January 2017 10:24:46 UTC+11, David Ford wrote:

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

0 Likes

#7

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

···

On Thu, Jan 19, 2017 at 6:40 PM Josh M josh.m...@tecevo.com wrote:

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.

On Friday, 20 January 2017 10:24:46 UTC+11, David Ford wrote:

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.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/bc1299fe-c705-4c48-a188-91cb6dcb7eca%40googlegroups.com.

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

0 Likes