crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 767 forks source link

self.authid not settable #1162

Closed Emantor closed 5 years ago

Emantor commented 5 years ago
crossbar URL: ws://127.0.0.1:20408/ws
crossbar realm: realm1
exporter name: dibooki
exporter hostname: dibooki
resource config file: export.yaml
2019-04-01T10:48:22 Future exception was never retrieved
future: <Future finished exception=AttributeError("can't set attribute")>
Traceback (most recent call last):
  File "/home/phoenix/.virtualenvs/labgrid-crossbar-bump/lib/python3.7/site-packages/txaio/aio.py", line 426, in as_future
    res = fun(*args, **kwargs)
  File "/home/phoenix/work/ptx/labgrid/labgrid/remote/exporter.py", line 321, in onConnect
    self.authid = "exporter/{}".format(self.name)
AttributeError: can't set attribute

Most likely due to the introduction of setters in #1137. Tested with latest labgrid master and a bump to crossbar and autobahn.

Am I supposed to set the authid differently? Code is here.

oberstet commented 5 years ago

you should not set this attribute: it is set internally during WAMP opening handshake

Emantor commented 5 years ago

Thanks.

oberstet commented 5 years ago

looking at your code, the fix is easy:

def onConnect(self):
    ...
    self.join(self.config.realm,
                 authmethods=["ticket"],
                 authid="exporter/{}".format(self.name))

sidenote: authid and authmethods are keyword arguments - technically, you can use positional args, but this might break should we ever reorder those (and since the function is kwarg based, that would "not break the interface")