crossbario / crossbar

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

Error with options on Web subtransport on a universal transport #1080

Closed oberstet closed 7 years ago

oberstet commented 7 years ago
2017-05-15T17:29:32+0000 [Router       1609] KeyError: 'endpoint': Traceback (most recent call last):
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/autobahn/twisted/websocket.py", line 162, in _onMessage
    self.onMessage(payload, isBinary)
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/autobahn/wamp/websocket.py", line 95, in onMessage
    self._session.onMessage(msg)
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/autobahn/wamp/protocol.py", line 892, in onMessage
    on_reply = txaio.as_future(endpoint.fn, *invoke_args, **invoke_kwargs)
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/txaio/tx.py", line 417, in as_future
    return maybeDeferred(fun, *args, **kwargs)
--- <exception caught here> ---
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/crossbar/worker/router.py", line 869, in start_router_transport
    web_factory = self._create_web_factory(config['web'])
  File "/home/ubuntu/crossbar-pypy2-1/site-packages/crossbar/worker/router.py", line 962, in _create_web_factory
    if 'tls' in config['endpoint']:
exceptions.KeyError: 'endpoint'

This is caused by a config like this:

                {
                    "type": "universal",
                    "endpoint": {
                        "type": "tcp",
                        "port": 443
                    },
                    "web": {
                        "options": {
                            "access_log": false,
                            "display_tracebacks": false,
                            "hsts": true,
                            "hsts_max_age": 31536000
                        },
                        "paths": {

The offending lines do:

        # HSTS
        if options.get('hsts', False):
            if 'tls' in config['endpoint']:
                hsts_max_age = int(options.get('hsts_max_age', 31536000))
                transport_factory.requestFactory = createHSTSRequestFactory(transport_factory.requestFactory, hsts_max_age)
            else:
                self.log.warn("Warning: HSTS requested, but running on non-TLS - skipping HSTS")
oberstet commented 7 years ago

Workaround is to remove the HSTS option for now:

                        "options": {
                            "access_log": false,
                            "display_tracebacks": false,
                            "hsts": true,
                            "hsts_max_age": 31536000
                        },