autobahn-js icon indicating copy to clipboard operation
autobahn-js copied to clipboard

Session detached after new session attached, resulting in `wamp.error.procedure_already_exists`

Open DamiToma opened this issue 1 year ago • 5 comments

I'm using Crossbar v20.12.3 and autobahn v20.9.2. Sometimes the onclose callback is called before the session is detached from the router.

I had a running process connected to the router with session ID 7159338250676650. Then, the onclose event was called at 2023-05-15T20:51:11.041Z with the following content

{
  "reason": "lost",
  "details": {
    "reason": null,
    "message": null,
    "retry_delay": 1.9348029488634622,
    "retry_count": 1,
    "will_retry": true
  }
}

In our implementation, we register all procedures that were registered before as soon as the connection is open again. So, as soon as we received the open event, we registered all procedures that were registered before. However, all of them failed to be created with the error wamp.error.procedure_already_exists. This should not be possible because we only try to register when the new session is connected.

After reviewing router logs, I found out that the previous session had its detached session log about 30 seconds after the new session connected. So my understanding is:

  1. Client lost connection at 20:51:11.041
  2. Router logged the new session at 20:51:13, below is the log 2023-05-15T20:51:13+0000 [Router 12] attached session 1165314019232070 to realm "myrealm" (authid="username", authrole="role") <crossbar.router.router.Router.attach>
  3. Client called the onopen callback at 20:51:13.512Z and it tried to register all procedures that were registered with the old session, however none of them worked because router still had to detach old session
  4. Router logged old session detachment at 20:51:46, below is the log 2023-05-15T20:51:46+0000 [Router 12] detached session 7159338250676650 from realm "myrealm" (authid="username", authrole="role", detached 1 sessions total) <crossbar.router.router.Router.detach>

So the question is, should the router detach the session before attaching the new one? Otherwise, how can we handle disconnections and register procedures again? Thanks!

DamiToma avatar May 16 '23 10:05 DamiToma