crossbario / crossbario/autobahn-python

Describe heartbeating for quick connection loss detection

Open
#1,095 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs enhancement
Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

Hi,

How can I make autobahn.twisted.component.Component notice lost of connection with router quickly?
Do I have any influence on time it takes?

I've tried couple of ideas but they seem not to work.

My case:
I have crossbar.io router with ping-pong specified. I have clients communicating with router using autobahn in Python 2.7 (on Ubuntu and on Mint).
I've created an autobahn.twisted.component.Component object and also keep access to Session object I've received at 'on component join'. If I lose connection to router, error 'wamp.close.transport_lost' is raised, then session leaves and component tries to reconnect. This is the scenario I like.

However when I lose connection (by unplugging the internet cable), it can take a lot of time before autobahn fires 'wamp.close.transport_lost. For clients running on Ubuntu it's around 10 sec. But for clients on Mint it's around 20 minutes.
I wish I could have a ping-pong with router, but I haven't found such an option for Component transport.

  1. I've tried to publish anything, so that component/session would notice that it has lost transport. But on Mint it takes around 20 minutes before it realizes.
  2. In documentation I found that I can define 'endpoint' with option 'timeout' on my own. However, after adding 'endpoint' with 'timeout' to my transport definition, I got the 'KeyError'.

Then I got another idea. I've decided to use simple python socket to check if I can connect to the port the crossbar.io listens on. If no, I know I have no connection with router for whatever reason. If yes, I need to verify if my session is still attached to the router. If it is not attached, I would use session.disconnect() and then session.leave(). After that 'wamp.close.transport_lost' is raised and Component starts reconnecting by himself.

How can I verify if my session is attached to the router?

  1. I've tried the method of session object "is_attached". However it returns 'True' even when my client is disconnected from the internet. After plugging the internet cable back, I keep receiving the same answer - True. But in fact the session is disconnected.

Could you give me some advice, how to achieve my goal?

Thanks for help
Dziad-yge

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the autobahn.twisted.component.Component and Session entry points, including the transport configuration and is_attached behavior mentioned in the report. Document the supported heartbeat or timeout configuration, how quickly connection loss is detected, and how a user can tell whether the session remains attached; confirm the guidance with a focused example or test if the repository provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, networking
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.