crossbario / crossbar

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

Update crossbar configuration files examples #60

Open sametmax opened 10 years ago

sametmax commented 10 years ago

I have been trying to test the Application in crossbar, but not matter how many examples I tried (and they are all differents), I seem to get errors. I'm suspecting many of them are out of date.

E.G, if i use this one :

https://github.com/crossbario/crossbar/wiki/Python-Application-Components#router-and-application-process

I end up with this error :

2014-05-31 20:57:28+0700 [Controller 2337] Invalid configuration: invalid attribute value 'router' for attribute 'type' in process item

If tried this :

https://github.com/crossbario/crossbar/wiki/Container-Configuration

I ended up with this error :

2014-05-31 21:38:59+0700 [Controller 3998] Invalid configuration: invalid attribute value 'component.python' for attribute 'type' in module item

I tried another one :

https://github.com/crossbario/crossbar/blob/master/example/config/config_new.json

And got the error :

2014-05-31 22:08:29+0700 [Controller 6050] Invalid configuration: encountered unknown attribute 'controller' in top-level configuration

I eventually got it working, after findling, trying various combinations and frankly, sometime pure guesses and sheer luck, and ended up with this:

JSON

{
   "processes": [
      {
         "type": "worker",
         "options": {
            "pythonpath": [".."]
         },
         "modules": [
            {
               "type": "router",
               "realms": {
                  "realm1": {
                     "permissions": {
                        "anonymous": {
                           "create": true,
                           "join": true,
                           "access": {
                              "*": {
                                 "publish": true,
                                 "subscribe": true,
                                 "call": true,
                                 "register": true
                              }
                           }
                        }
                     }
                  }
               },
               "transports": [
                  {
                     "type": "websocket",
                     "endpoint": {
                        "type": "tcp",
                        "port": 8080
                     }
                  }
               ]
            },
            {
               "type": "container",
               "component":  {
                  "type": "class",
                  "name": "app.app"
               },
               "router": {
                  "type": "websocket",
                  "endpoint": {
                     "type": "tcp",
                     "host": "localhost",
                     "port": 8080
                  },
                  "url": "ws://localhost:8080/ws",
                  "realm": "realm1"
               },
               "options": {
                  "pythonpath": [".."]
               }
            }
         ]
      }
   ]
}

If you explain to me all error messages and the current status of the configuration file, I can start updating the documentation.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2440023-update-crossbar-configuration-files-examples?utm_campaign=plugin&utm_content=tracker%2F462544&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F462544&utm_medium=issues&utm_source=github).
oberstet commented 10 years ago

Sorry for late response, I missed this one.

The entry point into all checking of configuration is the following function:

https://github.com/crossbario/crossbar/blob/master/crossbar/crossbar/common/checkconfig.py#L1380

This checks a complete local configuration file (config.json).

The reason this function is splitted into so many parts is the following: Crossbar today just reads a single local config. Crossbar tomorrow will allow to do everything via a remote management API. And hence, for example, starting a new Transport on a Router worker (already today) is done via:

https://github.com/crossbario/crossbar/blob/master/crossbar/crossbar/worker/router.py#L456

and there you can see the second use of the check_router_transport function

https://github.com/crossbario/crossbar/blob/master/crossbar/crossbar/worker/router.py#L478

Means: check_router_transport is called during checking of a complete config.json, but also if you call into the router via WAMP management API:

https://github.com/crossbario/crossbar/wiki/Management-API

oberstet commented 10 years ago

If you want to help, awesome!

wilbertom commented 10 years ago

I started digging throught the source code tonight. I'm taking notes on what I can see. My notes can be turned into a wiki page. I'll keep updates on my progress here so that when I'm done, we won't have to review huge notes.

Notes

Conventionally, passing a object of the wrong type or with a unknown attribute will raise an exception. Unless otherwise noted attributes are optional.


{
    "controller": {"id": not_checked, "realm": not_checked, "options": {"title": string}, "transport": "", "manhole": a_manhole},
    "workers": []
}

port_number = 1 >= integer >= 65535
backlog_number = 1 >= integer >= 65535
version_number = 4 | 6
boolean = true | false
tcp_endpoint = {
    "type": "tcp", 
    "version": version_number, 
    "port": port_number, 
    "shared": boolean, 
    "interface": string,
    "backlog": backlog_number, 
    "tls": {"key": string, "certificate": string, "dhparam": string, "ciphers": string}
}
unix_endpoint = {
    "type": "unix",
    "path": string,
    "backlog": backlog_number
}
a_manhole = {
    "endpoint": {"type": unix_endpoint | tcp_endpoint},
    "users": [
        user
    ]
}

user = {
    "username": "",
    "password": ""
}

Right now I'm on "transport": "" from the controller object in:


   if 'transport' in controller:
      ## FIXME: for now, only allow WAMP-WebSocket here
      check_listening_transport_websocket(controller['transport'])
goeddea commented 8 years ago

reopening as part of migrating the docs back into this repo