0

我想运行一个component具有一定角色的。但是每次我为我的组件设置“角色”参数时,Crossbar 服务器的运行就像其中有一个无限循环:我第一次进入页面时,一切正常,但是如果我刷新或打开另一个窗口到同一页面或即使另一个客户端打开此页面,该页面也会一遍又一遍地加载......

然后,如果我停止交叉开关服务器,我会在日志中多次显示此消息:[Controller 4422] waiting for 4433 to exit...

这是我的 conf.json:

{
  "controller": {
  },
  "workers": [
    {
      "type": "router",
      "options": {
        "pythonpath": [".."]
      },
      "realms": [
        {
          "name": "realm1",
          "roles": [
            {
              "name": "anonymous",
              "permissions": [
                {
                  "uri": "*",
                  "publish": true,
                  "subscribe": true,
                  "call": true,
                  "register": false
                }
              ]
            },
            {
              "name": "wamp_app",
              "permissions": [
                {
                  "uri": "*",
                  "publish": true,
                  "subscribe": true,
                  "call": true,
                  "register": true
                }
              ]
            }
          ]
        }
     ],
     "transports": [
       {
         "type": "web",
         "endpoint":{
           "type":"tcp",
           "port":8000
         },
         "paths": {
           "/": {
             "type": "wsgi",
             "module": "cyto_multihead.wsgi",
             "object": "application"
            },
            "lp": {
              "type": "longpoll"
            },
            "static": {
              "type": "static",
              "directory": "../static/"
            },
            "ws": {
              "type": "websocket"
            }
          }
        }
      ],
      "components": [
        {
          "type": "class",
          "classname": "crossbar_test.crossbar.MyComponent",
          "realm": "realm1",
          "role": "wamp_app"
        }
      ]
    }
  ]
}

我的文件是这样放置的:

my_project_directory/
  .crossbar/
    config.json
  crossbar_test/
    crossbar.py

此外,如果我不指定角色,则服务器不会以此错误启动:

[Router      28146] --- <exception caught here> ---
[Router      28146] File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred
[Router      28146] result = f(*args, **kw)
[Router      28146] File "/usr/local/lib/python2.7/dist-packages/crossbar/worker/router.py", line 510, in start_router_component
[Router      28146] self.session_factory.add(session, authrole=config.get('role', 'anonymous'))
[Router      28146] File "/usr/local/lib/python2.7/dist-packages/crossbar/router/session.py", line 470, in add
[Router      28146] self._app_sessions[session] = RouterApplicationSession(session, self._routerFactory, authid, authrole)
[Router      28146] File "/usr/local/lib/python2.7/dist-packages/crossbar/router/session.py", line 88, in __init__
[Router      28146] assert(authrole is None or isinstance(authrole, six.text_type))
[Router      28146] exceptions.AssertionError:
[Router      28146] 'Failure while invoking procedure <bound method RouterWorkerSession.start_router_component of <crossbar.worker.router.RouterWorkerSession object at 0x7fc1a4484cd0>> registered under "crossbar.node.conan.worker.worker1.start_router_component".'
[Controller  28135] Traceback (most recent call last):
[Controller  28135]   File "/usr/local/lib/python2.7/dist-packages/crossbar/controller/node.py", line 183, in run_node_config
[Controller  28135]     yield self._run_node_config(config)
[Controller  28135] ApplicationError: ApplicationError('wamp.error.runtime_error', args = (), kwargs = {})
[Controller  28135] sending TERM to subprocess 28146
[Controller  28135] waiting for 28146 to exit...
[Router      28146] Received SIGTERM, shutting down.
[Router      28146] Connection to node controller lost.
[Router      28146] Main loop terminated.
[Controller  28135] Worker 28146: Process connection gone (Connection was closed cleanly.)
[Controller  28135] Main loop terminated.

我的配置有什么问题?

4

1 回答 1

0

我认为问题来自以下配置:

"/": {
  "type": "wsgi",
  "module": "cyto_multihead.wsgi",
  "object": "application"
},

如果您更改配置,例如:

"/": {
  "type": "static",
  "directory": "../hello/web"
},

Crossbar 将成功运行。

于 2015-12-08T08:55:21.677 回答