[Python] Autobahn Application Runner is not running Apps

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm pretty new to Autobahn and WAMP (Web Apps Messaging Protocol).

    I'm just creating a simple Application Component based on [this documentation](web.archive.org/web/20140417162256/http://autobahn.ws/python/wamp/programming.html] and and this example

    My server-side Python code:

    from autobahn.asyncio.wamp import (
    ApplicationSession,
    ApplicationRunner
    )
    from autobahn import wamp

    from asyncio import coroutine

    class MyComponent(ApplicationSession):
    @wamp.register("com.myapp.add2")
    def add2(self, x, y):
    print("added 2")
    return x + y

    @wamp.register("com.myapp.add3")
    def add3(self, x, y, z):
    print("added 3")
    return x + y + z

    @coroutine
    def onJoin(self, details):
    res = yield from self.register(self)
    print("{} procedures registered.".format(len(res)))

    if __name__ == '__main__':
    runner = ApplicationRunner(url="ws://localhost:8080/ws", realm="realm1")
    runner.run(MyComponent)


    And the client-side code

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    </head>
    <body>
    <script>AUTOBAHN_DEBUG = false;</script>
    <script src="http://autobahn.s3.amazonaws.com/autobahnjs/latest/autobahn.min.jgz"></script>

    <script>
    var connection = new autobahn.Connection({
    url: "ws://localhost:8080/ws",
    realm: "realm1"
    });

    connection.onopen = function (session, details) {
    session.call("com.myapp.add2", [2,3]).then(session.log);
    session.call("com.myapp.add3", [2,3,4]).then(session.log);
    };

    connection.onclose = function (reason, details) {
    console.log("Connection lost: " + reason);
    };

    connection.open();
    </script>
    </body>
    </html>


    Error:

    [​IMG]

    Looks like this is similar to https://github.com/hwmrocker/hextest/issues/2 but I can't get my head around. I can't even find a sample that works. This one (https://github.com/tavendo/AutobahnPython/tree/master/examples/asyncio/wamp/wamplet/wamplet1) is similar but it has the same issue as well.

    Surprisingly, when I run an external Crossbar sample on the same Port and run the above example, it works like a magic and I can see the results on the console.

    I found this one (https://github.com/tavendo/AutobahnPython/blob/master/examples/asyncio/wamp/basic/server.py) but it looks quite complicated.

    Continue reading...

Compartilhe esta Página