crossbario / crossbar

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

Router error on session_left #1040

Closed d29 closed 7 years ago

d29 commented 7 years ago

crossbar version

 Crossbar.io        : 17.3.1 (Crossbar.io COMMUNITY)
   Autobahn         : 0.18.1 (with JSON, MessagePack, CBOR, UBJSON)
   Twisted          : 17.1.0-EPollReactor
   LMDB             : 0.92/lmdb-0.9.18
   Python           : 3.6.1/CPython
 OS                 : Linux-3.13.0-110-generic-x86_64-with-debian-jessie-sid
 Machine            : x86_64
 Release key        : RWRGxs0uB6vQemWGPeBt7nLG53ADoOtZy/Vve3BjlaXDqkCiVhCs7Zrv

Traceback from router:

2017-04-13T10:31:31-0700 [Router      15720] Traceback (most recent call last):
  File "/home/user/dev/venv/lib/python3.6/site-packages/autobahn/wamp/websocket.py", line 95, in onMessage
    self._session.onMessage(msg)
  File "/home/user/dev/venv/lib/python3.6/site-packages/crossbar/router/session.py", line 468, in onMessage
    self.onLeave(types.CloseDetails(msg.reason, msg.message))
  File "/home/user/dev/venv/lib/python3.6/site-packages/crossbar/router/session.py", line 774, in onLeave
    self._router._session_left(self, self._session_details)
AttributeError: 'NoneType' object has no attribute '_session_left'

js code to reproduce:

var connection = new autobahn.Connection({
    url: 'ws://127.0.0.1:8080/ws',
    realm: 'realm',
    authid: "user",
    authmethods: ['ticket']
});

connection.open();
DZabavchik commented 7 years ago

This also appears to leave zombie registrations. So when client reconnects and tries to re-register same URI error is returned that it is already registered. The only way to resolve is to restart the router

meejah commented 7 years ago

From code-inspection, it looks like this particular problem should be fixed on master (because that line of code is now inside a block checking self._router for None).

From the diffs, I think it was introduced between 17.2.0 and 17.3.x.

@d29 if you have a way to reliably repeat this, can you try with master? You can pip install https://github.com/crossbario/crossbar/archive/master.zip to do that.

You can repeat this (on 17.2.x) IIRC by raising a non-ApplicationError exception from a dynamic authenticator, causing the session to leave before it is fully joined. However, in that case there wouldn't be any registrations anyway.

DZabavchik commented 7 years ago

Thanks @meejah. Yes, the main issue here is zombie registrations. Unfortunately I don't have a reliable way to reproduce it. Ended up backporting some modifications I needed to 0.15, because it doesn't have that issue - registrations are reliably removed when session disconnects cleanly or not.

Hunch: any chance exception is thrown when session is being discarded (removed) and all of the new code that logs session leaving is invoked. Again, sorry, I don't have any debug logs or reliable way to reproduce.

meejah commented 7 years ago

Okay. To clarify: I don't think the stacktrace in the original report can still happen (on master), but that doesn't mean there aren't other ways to get zombie registrations :/

meejah commented 7 years ago

@DZabavchik Thanks. Yeah, I'd presume something like that. Have you tried anything newer than 0.15? I can look at the diffs and see if anything pops out ...

oberstet commented 7 years ago

There is guarding code on master that prohibits this.