noisyboiler / wampy

Websocket RPC and Pub/Sub for Python applications and microservices
Mozilla Public License 2.0
127 stars 24 forks source link

Cannot receive result from RPC to autobahn callee #75

Closed goranpetrovikj closed 5 years ago

goranpetrovikj commented 6 years ago

I start an autobahn callee and leave it running. I start the wampy caller and it results with the error below. However, i can see that the callee receives the call and replies to it. The problem is that the result cannot be retrieved using the wampy client.

Happens on all releases that we tried (0.9.14, 0.9.17) and latest master (commit 1cc127c85b7d73a7324238fea7f8875ae3a855a3)

Error:

Traceback (most recent call last):
  File "/home/goran/workspace/tmp/wampy_bug_caller.py", line 7, in <module>
    result = client.call("ping")
  File "/home/goran/.local/share/virtualenvs/tmp-yHIhTlRE/lib/python3.5/site-packages/wampy/roles/caller.py", line 40, in __call__
    return response.value
  File "/home/goran/.local/share/virtualenvs/tmp-yHIhTlRE/lib/python3.5/site-packages/wampy/messages/result.py", line 46, in value
    return self.yield_kwargs['message']
TypeError: 'NoneType' object is not subscriptable

Autobahn callee:

from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner

class Component(ApplicationSession):
    async def onJoin(self, details):

        def ping():
            print("Replying with 'pong' to {}".format(details.realm))
            return 'pong'

        reg = await self.register(ping, 'ping')
        print("Registered 'ping' with id {}".format(reg.id))

if __name__ == '__main__':
    ROUTER_URL = 'ws://localhost:8080/ws'
    REALM = 'crossbardemo'
    runner = ApplicationRunner(ROUTER_URL, REALM)
    runner.run(Component)

Wampy caller:

from wampy.peers import Client

ROUTER_URL = 'ws://localhost:8080/ws'
REALM = 'crossbardemo'

with Client(url=ROUTER_URL, realm=REALM) as client:
    result = client.call("ping")
    print(result)

I managed to make the code work by implementing this code in wampy/messages/result.py:

    @property
    def value(self):
        if self.yield_kwargs:
            return self.yield_kwargs['message']
        return self.yield_args[0]
noisyboiler commented 5 years ago

hiya @goranpetrovikj thank you for this. yeah.... wampy doesn't support the kwargs yet! please raise a PR? I'd like to get your contribution into the project. Thanks again Simon

noisyboiler commented 5 years ago

looking at the bottom of README i must have identified an issue similar to what you've encountered before. is there a connection?

noisyboiler commented 5 years ago

thanks for raising and addressing this issue. šŸ‘