voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
676 stars 117 forks source link

wamp.error.procedure_already_exists when client reconnects after connection was dropped by ISP #346

Closed Sebastian-Habiger closed 4 years ago

Sebastian-Habiger commented 4 years ago

Hi, thanks for that awesome package. I am using a thruway router on our server and we have a few external client services (node+autobahn) that connect to the router and register their service functions. After a forced reconnection by the ISP a client tries to reconnect and registers its methods again. But as the router did not recognize that the previous connection was dropped the previous session and all its registrations still exist. So the client gets the error wamp.error.procedure_already_exists.

Is there any option inside thruway that can detect this situation and clean up all broken sessions? Maybe using Ping/Pong?

Any help or suggestions to handle that circumstance would be highly appreciated.

Thanks in advance.

mbonneau commented 4 years ago

@Sebastian-Habiger I am glad that this package is working well for you.

Thruway has a registration option 'replace_orphaned_session' => 'yes' that will unregister an existing RPC registration when you reregister. I am not sure if autobahn will allow you to send this option with the registration because they are a little more strict about that stuff than they were in the past and we don't use autobahn clients as much as we used to.

Let me know if this helps.

Sebastian-Habiger commented 4 years ago

First of all that solved the problem. Thank you, for the quick response.

There is a small issue with the strict types as IRegisterOptions does not define replace_orphaned_session, but casting the options to any type helps. After that, the old session is closed by Thruway when it receives the new registration.

session.register(uri, method, { replace_orphaned_session: 'yes' } as any);