crossbario / crossbar

Crossbar.io - WAMP application router
https://crossbar.io/
Other
2.05k stars 275 forks source link

Personality has no attribute create_web_service #1773

Closed om26er closed 4 years ago

om26er commented 4 years ago

Nested paths causes crossbar start failure.

(venv) om26er@X1C6:~/Documents$ crossbar start

2020-06-02T14:55:22+0500 [Controller  24170] 
2020-06-02T14:55:22+0500 [Controller  24170]     :::::::::::::::::
2020-06-02T14:55:22+0500 [Controller  24170]           :::::          _____                      __
2020-06-02T14:55:22+0500 [Controller  24170]     :::::   :   :::::   / ___/____ ___   ___  ___  / /  ___ _ ____
2020-06-02T14:55:22+0500 [Controller  24170]     :::::::   :::::::  / /__ / __// _ \ (_-< (_-< / _ \/ _ `// __/
2020-06-02T14:55:22+0500 [Controller  24170]     :::::   :   :::::  \___//_/   \___//___//___//_.__/\_,_//_/
2020-06-02T14:55:22+0500 [Controller  24170]           :::::
2020-06-02T14:55:22+0500 [Controller  24170]     :::::::::::::::::   Crossbar v20.5.1.dev1
2020-06-02T14:55:22+0500 [Controller  24170] 
2020-06-02T14:55:22+0500 [Controller  24170]     Copyright (c) 2013-2020 Crossbar.io Technologies GmbH, licensed under AGPL 3.0.
2020-06-02T14:55:22+0500 [Controller  24170] 
2020-06-02T14:55:22+0500 [Controller  24170] Booting standalone node .. <crossbar.node.main._run_command_start>
2020-06-02T14:55:22+0500 [Controller  24170] Node key files exist and are valid. Node public key is 0xb0a7eb96fe326518845245c3bd6ba88270e18f6aa3ba10dd3d9cfa6713a51cad
2020-06-02T14:55:22+0500 [Controller  24170] Node key loaded from /home/om26er/Documents/.crossbar/key.priv
2020-06-02T14:55:22+0500 [Controller  24170] Node configuration loaded [config_source=localfile, config_path=/home/om26er/Documents/.crossbar/config.json]
2020-06-02T14:55:22+0500 [Controller  24170] Entering event reactor ...
2020-06-02T14:55:22+0500 [Controller  24170] Starting node .. [<crossbar.node.node.Node.start>]
2020-06-02T14:55:22+0500 [Controller  24170] Node ID x1c6-24170 set from hostname/pid
2020-06-02T14:55:22+0500 [Controller  24170] RouterFactory.start_realm: router created for realm "crossbar"
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.node.node.Node._add_global_roles> node-wide role "controller" added on node management router realm "crossbar"
2020-06-02T14:55:22+0500 [Controller  24170] attached session 7840515337214136 to realm "crossbar" (authid="serviceagent", authrole="trusted") <crossbar.router.router.Router.attach>
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.router.service.RouterServiceAgent.onJoin>: realm service session attached to realm "crossbar" [session_id=7840515337214136, authid="serviceagent", authrole="trusted", on_ready=None]
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.node.node.Node.start> router service agent session attached [<crossbar.router.service.RouterServiceAgent>]
2020-06-02T14:55:22+0500 [Controller  24170] attached session 2386556452981306 to realm "crossbar" (authid="nodecontroller", authrole="controller") <crossbar.router.router.Router.attach>
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.node.controller.NodeController.onJoin>: joined realm="crossbar" on local node management router [authid="nodecontroller", authrole="controller"]
2020-06-02T14:55:22+0500 [Controller  24170] Ok, registered 23 management procedures on realm "crossbar".
2020-06-02T14:55:22+0500 [Controller  24170] Signal handler installed on process 24170 thread 140612017829696
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.node.node.Node.start> node controller session attached [<crossbar.node.controller.NodeController>]
2020-06-02T14:55:22+0500 [Controller  24170] Using default node shutdown triggers ['shutdown_on_worker_exit']
2020-06-02T14:55:22+0500 [Controller  24170] <crossbar.node.node.Node.boot>::NODE_BOOT_BEGIN
2020-06-02T14:55:22+0500 [Controller  24170] Booting node <crossbar.node.node.Node.boot>
2020-06-02T14:55:22+0500 [Controller  24170] Booting node from local configuration [parallel_worker_start=False] .. <crossbar.node.node.Node.boot_from_config>
2020-06-02T14:55:22+0500 [Controller  24170] Will start 1 worker ..
2020-06-02T14:55:22+0500 [Controller  24170] Order node to start "Router worker001" ..
2020-06-02T14:55:22+0500 [Controller  24170] Starting router-worker "worker001" .. <crossbar.node.controller.NodeController.start_worker>
2020-06-02T14:55:22+0500 [Controller  24170] worker-specific role "crossbar.worker.worker001" added on node management router realm "crossbar" <crossbar.node.node.Node._add_worker_role>

2020-06-02T14:55:22+0500 [Router      24173] Starting router-worker "worker001" on node "x1c6-24170" (personality "standalone") and local node management realm "crossbar" .. <crossbar.worker.router.RouterController>
2020-06-02T14:55:22+0500 [Router      24173] Running as PID 24173 on CPython-EPollReactor
2020-06-02T14:55:22+0500 [Router      24173] Entering event reactor ...
2020-06-02T14:55:22+0500 [Controller  24170] attached session 2411531171534416 to realm "crossbar" (authid="crossbar.process.24173", authrole="crossbar.worker.worker001") <crossbar.router.router.Router.attach>
2020-06-02T14:55:22+0500 [Router      24173] Router worker session for "worker001" joined realm "crossbar" on node router <crossbar.worker.router.RouterController.onJoin>
2020-06-02T14:55:22+0500 [Router      24173] Ok, registered 49 management procedures on realm "crossbar".
2020-06-02T14:55:22+0500 [Router      24173] Router worker session for "worker001" ready
2020-06-02T14:55:22+0500 [Controller  24170] Ok, node has started Router worker001
2020-06-02T14:55:22+0500 [Controller  24170] Configuring Router worker001 ..
2020-06-02T14:55:22+0500 [Controller  24170] Order Router worker001 to start Realm realm001
2020-06-02T14:55:22+0500 [Router      24173] Starting router realm realm001 <crossbar.worker.router.RouterController.start_router_realm>
2020-06-02T14:55:22+0500 [Router      24173] RouterFactory.start_realm: router created for realm "realm1"
2020-06-02T14:55:22+0500 [Router      24173] attached session 5940635253142629 to realm "realm1" (authid="routerworker-worker001-realm-realm001-serviceagent", authrole="trusted") <crossbar.router.router.Router.attach>
2020-06-02T14:55:22+0500 [Router      24173] <crossbar.router.service.RouterServiceAgent.onJoin>: realm service session attached to realm "realm1" [session_id=5940635253142629, authid="routerworker-worker001-realm-realm001-serviceagent", authrole="trusted", on_ready=<Deferred at 0x7ff0ff8d2c10>]
2020-06-02T14:55:22+0500 [Router      24173] <crossbar.worker.router.RouterController.set_service_session>(session=<crossbar.router.service.RouterServiceAgent object at 0x7ff0ff8130a0>, realm="realm1", authrole="trusted")
2020-06-02T14:55:22+0500 [Router      24173] RouterServiceAgent started on realm="realm1" with authrole="trusted", authid="routerworker-worker001-realm-realm001-serviceagent"
2020-06-02T14:55:22+0500 [Router      24173] Realm "realm001" (name="realm1", authrole="trusted", authid="routerworker-worker001-realm-realm001-serviceagent") started
2020-06-02T14:55:22+0500 [Controller  24170] Ok, Router worker001 has started Realm realm001
2020-06-02T14:55:22+0500 [Controller  24170] Order Realm realm001 to start Role role001
2020-06-02T14:55:22+0500 [Router      24173] Role role001 named "anonymous" started on realm "realm1"
2020-06-02T14:55:22+0500 [Controller  24170] Ok, Realm realm001 has started Role role001
2020-06-02T14:55:22+0500 [Controller  24170] Order Router worker001 to start Transport transport001
2020-06-02T14:55:22+0500 [Router      24173] Starting router transport "transport001" <crossbar.worker.router.RouterController.start_router_transport>
2020-06-02T14:55:22+0500 [Router      24173] Creating router transport for "transport001" ..
2020-06-02T14:55:22+0500 [Router      24173] Router transport created for "transport001" [transport_class=<crossbar.worker.transport.RouterTransport>]
2020-06-02T14:55:22+0500 [Router      24173] WampWebSocketServerFactory starting on 8089
2020-06-02T14:55:22+0500 [Controller  24170] Ok, Router worker001 has started Transport transport001
2020-06-02T14:55:22+0500 [Controller  24170] Order Router worker001 to start Transport transport002
2020-06-02T14:55:22+0500 [Router      24173] Starting router transport "transport002" <crossbar.worker.router.RouterController.start_router_transport>
2020-06-02T14:55:22+0500 [Router      24173] Creating router transport for "transport002" ..
2020-06-02T14:55:22+0500 [Router      24173] Router transport created for "transport002" [transport_class=<crossbar.worker.transport.RouterWebTransport>]
2020-06-02T14:55:22+0500 [Router      24173] Created "path" Web service on root path "/" of Web transport "transport002"
2020-06-02T14:55:22+0500 [Router      24173] Site starting on 8088
2020-06-02T14:55:22+0500 [Controller  24170] Ok, Router worker001 has started Transport transport002
2020-06-02T14:55:22+0500 [Controller  24170] Order Transport transport002 to start Web Service webservice001
2020-06-02T14:55:22+0500 [Router      24173] Starting "path" Web service on path "market1" of transport "transport002" <crossbar.worker.router._TransportController.start_web_transport_service>
2020-06-02T14:55:22+0500 [Router      24173] RouterController.onUserError(): "AttributeError: type object 'Personality' has no attribute 'create_web_service'"
Traceback (most recent call last):
  File "/home/om26er/scm/crossbario/crossbar/venv/lib/python3.8/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "/home/om26er/scm/crossbario/crossbar/venv/lib/python3.8/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
  File "/home/om26er/scm/crossbario/crossbar/venv/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/home/om26er/scm/crossbario/crossbar/crossbar/worker/router.py", line 120, in start_web_transport_service
    webservice = yield maybeDeferred(webservice_factory.create, transport, path, config)
--- <exception caught here> ---
  File "/home/om26er/scm/crossbario/crossbar/crossbar/worker/router.py", line 120, in start_web_transport_service
    webservice = yield maybeDeferred(webservice_factory.create, transport, path, config)
  File "/home/om26er/scm/crossbario/crossbar/venv/lib/python3.8/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
    result = f(*args, **kw)
  File "/home/om26er/scm/crossbario/crossbar/crossbar/webservice/base.py", line 357, in create
    resource = personality.create_web_service(personality, transport.worker._reactor, nested_paths['/'], transport.templates, transport.cbdir)
builtins.AttributeError: type object 'Personality' has no attribute 'create_web_service'

2020-06-02T14:55:22+0500 [Controller  24170] Could not start node: Traceback (most recent call last):
--- <exception caught here> ---
  File "/home/om26er/scm/crossbario/crossbar/crossbar/node/node.py", line 460, in start
    yield self.personality.Node.boot(self)
  File "/home/om26er/scm/crossbario/crossbar/crossbar/node/node.py", line 597, in boot_from_config
    yield d
  File "/home/om26er/scm/crossbario/crossbar/crossbar/node/node.py", line 570, in configure_worker
    yield config_fn(worker_logname, worker_id, worker)
  File "/home/om26er/scm/crossbario/crossbar/crossbar/node/node.py", line 756, in _configure_native_worker_router
    yield self._controller.call('crossbar.worker.{}.start_web_transport_service'.format(worker_id),
autobahn.wamp.exception.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=["type object 'Personality' has no attribute 'create_web_service'"], kwargs={}, enc_algo=None, callee=None, callee_authid=None, callee_authrole=None, forward_for=None)

2020-06-02T14:55:22+0500 [Controller  24170] sending TERM to subprocess 24173
2020-06-02T14:55:22+0500 [Controller  24170] waiting for 24173 to exit...
2020-06-02T14:55:22+0500 [Router      24173] Native worker received SIGTERM - shutting down ..
2020-06-02T14:55:22+0500 [Router      24173] Shutdown of worker requested!
2020-06-02T14:55:22+0500 [Controller  24170] detached session 2411531171534416 from realm "crossbar" (authid="crossbar.process.24173", authrole="crossbar.worker.worker001", detached 1 sessions total) <crossbar.router.router.Router.detach>
2020-06-02T14:55:22+0500 [Router      24173] Connection to node controller closed cleanly
2020-06-02T14:55:22+0500 [Router      24173] (TCP Port 8089 Closed)
2020-06-02T14:55:22+0500 [Router      24173] (TCP Port 8088 Closed)
2020-06-02T14:55:22+0500 [Controller  24170] Native worker connection closed cleanly.
2020-06-02T14:55:22+0500 [Controller  24170] Node worker worker001 ended successfully
2020-06-02T14:55:22+0500 [Controller  24170] Checking for node shutdown: worker_exit_success=True, shutdown_requested=False, node_shutdown_triggers=['shutdown_on_worker_exit']
2020-06-02T14:55:22+0500 [Controller  24170] Node worker ended, and trigger 'shutdown_on_worker_exit' is active: will shutdown node ..
2020-06-02T14:55:22+0500 [Controller  24170] Node shutdown requested (restart=False, mode=None, reactor.running=True) ..
om26er commented 4 years ago

Here is the related to crossbar config

{
    "$schema": "https://raw.githubusercontent.com/crossbario/crossbar/master/crossbar.json",
    "version": 2,
    "controller": {
    },
    "workers": [
        {
            "type": "router",
            "realms": [
                {
                    "name": "realm1",
                    "roles": [
                        {
                            "name": "anonymous",
                            "permissions": [
                                {
                                    "uri": "",
                                    "match": "prefix",
                                    "allow": {
                                        "call": true,
                                        "register": true,
                                        "publish": true,
                                        "subscribe": true
                                    },
                                    "disclose": {
                                        "caller": false,
                                        "publisher": false
                                    },
                                    "cache": true
                                }
                            ]
                        }
                    ]
                }
            ],
            "transports": [
                {
                    "type": "websocket",
                    "endpoint": {
                        "type": "tcp",
                        "port": 8089,
                        "backlog": 1024
                    }
                },
                {
                    "type": "web",
                    "endpoint": {
                        "type": "tcp",
                        "port": 8088,
                        "backlog": 1024
                    },
                    "paths": {
                        "ws": {
                            "type": "websocket"
                        },
                        "market1": {
                            "type": "path",
                            "paths": {
                                "/": {
                                    "type": "archive",
                                    "archive": "markets-ui.zip",
                                    "origin": "http://localhost:9000/markets-ui.zip"
                                },
                                "config": {
                                    "type": "json",
                                    "value": {
                                        "url": "ws://localhost:8080/ws",
                                        "realm": "testing"
                                    }
                                }
                            }
                        }
                    }
                }
            ]
        }
    ]
}
om26er commented 4 years ago

I looked inside the code, the issue happens here https://github.com/crossbario/crossbar/blob/master/crossbar/webservice/base.py#L357 and it seems create_web_service doesn't really exist. Something that got missed/removed during a refactor maybe ?

meejah commented 4 years ago

introduced here: https://github.com/crossbario/crossbar/commit/b33a1e661b8ff1e774ed0734f141a7659c2d9516

oberstet commented 4 years ago

no sure where/when this originates. the removed attribute came from this import:

from crossbar.worker.transport.resource import create_web_service, add_web_services, remove_web_services

so there must have been a resource.py at some point? but somehow I can't find that ..

oberstet commented 4 years ago

Omer found it;) here https://github.com/crossbario/crossbar/blob/8e93b9ad45a64ef96bdb60825fdcf4cf5e2617c3/crossbar/worker/transport/resource.py

oberstet commented 4 years ago

fixed via https://github.com/crossbario/crossbar/pull/1780 see https://github.com/crossbario/crossbar-examples/tree/master/webservices/path

to test (above example):

oberstet@intel-nuci7:~/scm/crossbario/crossbar-examples/webservices/path$ make test  
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41

(stdin)= efd3112dd986b472fc9260b166a8e27e64f78084f83f4bca61d34810adadefde
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41

(stdin)= 1317d0892b0f4297391be9a2b239503bd9fa8fc5d8b06f3ccf36fdec8f42cbb9
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41

(stdin)= 301f06d2a426f1e4afd14d2a8f96602411b2425cbcfee47b5202029ead7eefad
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41
(stdin)= 9c86c3c20ad4c9dd46ff53d18e593e25e0d872eed2460eb44344f6f28a042a41

(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683
(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683

(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683
(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683

(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683
(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683

(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683
(stdin)= 82dbb6367aced3f6b1c8ed0240a56a4b8ecddddade392b3eb2393e0e289c2683

(stdin)= 3ce7faa29cad80f4814fcc0618a257d3d08103d1658af6cf48a52839877cc730
(stdin)= 65a21e590fb89c4a5607645526d4c88ecb5b914440a87917d7ce39a17568d52b

(stdin)= 3ce7faa29cad80f4814fcc0618a257d3d08103d1658af6cf48a52839877cc730
(stdin)= 65a21e590fb89c4a5607645526d4c88ecb5b914440a87917d7ce39a17568d52b

(stdin)= 3ce7faa29cad80f4814fcc0618a257d3d08103d1658af6cf48a52839877cc730
(stdin)= 65a21e590fb89c4a5607645526d4c88ecb5b914440a87917d7ce39a17568d52b

(stdin)= 3ce7faa29cad80f4814fcc0618a257d3d08103d1658af6cf48a52839877cc730
(stdin)= 65a21e590fb89c4a5607645526d4c88ecb5b914440a87917d7ce39a17568d52b

(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a
(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a

(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a
(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a

(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a
(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a

(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a
(stdin)= 879b60ca95a98091fc3635779a970da9a19c9aec6de6c0846787e56cef01bf5a

you will notice some hashes don't line up .. the reason is that some of our webservice don't like a trailing "/"

this might be an easy fix somewhere adding a getChild or what - but I'm too tired now to hunt it down;) maybe @meejah has the answer right in his pocket.

in any case, doesn't matter for what we need now ..