C++ - Call RPC from within RPC handler

#1

All,

Has anyone successfully worked out how to call an RPC from within an RPC handler?

Even if nobody has a solution, I’ll take shots in the dark/random ideas.

For reference, this person had asked a similar question: https://groups.google.com/d/msg/autobahnws/Zwoue4pT1js/_NNUgT8loOwJ

Explanation:

I have a client that provides an RPC. When that RPC invoked, the handler may need to call an RPC on another client to get additional information. However, when I attempt to get the result from the nested RPC, the process deadlocks.

As far as I can tell, and I’m still a little hazy on Boost’s I/O service, the reason for this is that the I/O service is attempting to dispatch the handler, which is currently blocked by the attempt to get the result from the nested call, and never actually executes the nested call because it’s been queued up to run after the handler from which it was invoked.

I’ve tried using multiple threads executing the same IO service, but the process still locks when I attempt to get the nested result. I suppose the easy way to get around this is to create a separate WAMP client (with separate I/O service) just for the nested request. This is undesirable for this particular project, so I’m looking for other ideas until I’m told this isn’t possible.

If it helps, the workflow I’m going for is something like this:

0 Likes

#2

Hi, out of interest, can I ask why you’re working in C++ rather than a scripting language? (i.e. Python or node?)

Just out of interest I tried this in Python on my dev code, so within a registered RPC call I inserted;

    x = yield self.server.call(u'nac.rpc.test.routine')
    log.msg("X=",x)

``

Then I added this to the same source file;

@wamp.register(u'nac.rpc.test.routine')
def nac_rpc_test_routine(self, details):
    return "I don't do anything"

``

And when the first RPC call is executed from a JS browser client I see;

2016-06-10T09:29:33+0100 X= I don’t do anything

``

0 Likes

#3

I’m working in C++ because it’s a requirement of the project and that decision is not up to me.

I already know that what I need to do works in Python.

···

On Friday, June 10, 2016 at 4:35:15 AM UTC-4, Gareth Bult wrote:

Hi, out of interest, can I ask why you’re working in C++ rather than a scripting language? (i.e. Python or node?)

Just out of interest I tried this in Python on my dev code, so within a registered RPC call I inserted;

    x = yield self.server.call(u'nac.rpc.test.routine')
    log.msg("X=",x)

``

Then I added this to the same source file;

@wamp.register(u'nac.rpc.test.routine')
def nac_rpc_test_routine(self, details):
    return "I don't do anything"

``

And when the first RPC call is executed from a JS browser client I see;

2016-06-10T09:29:33+0100 X= I don’t do anything

``

0 Likes