crossbario / crossbar

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

Null session ID in registration/subscription meta events when callee/subscriber leaves #2084

Open ecorm opened 1 year ago

ecorm commented 1 year ago

When a callee leaves, the wamp.registration.on_unregister meta event that is emitted contains a null session id argument instead of an expected integer. The same thing happens with the wamp.registration.on_delete meta event.

The same goes for a subscriber leaving. When a subscriber leaves, the wamp.subscription.on_subscribe meta event that is emitted contains a null session id argument instead of an expected integer. The same thing happens with the wamp.subscription.on_delete meta event.

Is the null session ID intentional is these cases, due to callee/subscriber session no longer existing? The WAMP spec lists session|id as the first positional argument, and does not mention anything about it being nullable.

This is with Crossbar v.23.1.2.

oberstet commented 1 year ago

The WAMP spec lists session|id as the first positional argument, and does not mention anything about it being nullable.

yes, the session_id must be filled (not null). and this should be filled for both these cases:

  1. subscriber explicitly unsubscribes while the session itself remains open
  2. subscriber session leaves - deliberately or otherwise - and the subscription ends implicitly because the subscribed session is gone

that means: if crossbar doesn't fill it, that's a bug.

here is the sequence of code that I think is run.

the ID is fetched from session._session_id where session is a crossbar.router.session.RouterSession

https://github.com/crossbario/crossbar/blob/03d7057ee18a0d1e59b33bf1633ee246c1cf908a/crossbar/router/session.py#LL390C7-L390C20

the 2 cases above are exactly here

oberstet@intel-nuci7:~$ find scm/crossbario/crossbar/crossbar -name "*.py" -exec grep -Hin "on_unregister" {} \;
scm/crossbario/crossbar/crossbar/router/dealer.py:257:                                'wamp.registration.on_unregister',
scm/crossbario/crossbar/crossbar/router/dealer.py:660:                    service_session.publish('wamp.registration.on_unregister',
  1. crossbar.router.Dealer._unregister

https://github.com/crossbario/crossbar/blob/03d7057ee18a0d1e59b33bf1633ee246c1cf908a/crossbar/router/dealer.py#L660

  1. crossbar.router.Dealer.detach

https://github.com/crossbario/crossbar/blob/03d7057ee18a0d1e59b33bf1633ee246c1cf908a/crossbar/router/dealer.py#L257


not sure what might go wrong ... thing is, there are only a couple of places where _session_id is set None:

oberstet@intel-nuci7:~$ find scm/crossbario/crossbar/crossbar -name "*.py" -exec grep -Hin "\._session_id = None" {} \;

scm/crossbario/crossbar/crossbar/worker/proxy.py:121:        self._session_id = None
scm/crossbario/crossbar/crossbar/router/session.py:436:        self._session_id = None
scm/crossbario/crossbar/crossbar/router/session.py:637:                self._session_id = None
scm/crossbario/crossbar/crossbar/router/session.py:685:                self._session_id = None
scm/crossbario/crossbar/crossbar/router/session.py:746:            self._session_id = None
scm/crossbario/crossbar/crossbar/router/session.py:791:        self._session_id = None
ecorm commented 1 year ago

I've seen those nulls in the raw JSON message dumps while I was debugging, so I'm very confident it's not a problem on my end.