Skip to content

[BUG] FBNS MQTT Timeout on read causes a disconnection #402

Description

@qwer-lives

What broke?

This is a consequence the fix for #396. It is now marking connected = False for all exceptions on fbns._recv_packet. However, it is natural to sometimes receive a timeout when trying to read, for example if not pinging often enough. This shouldn't disconnect the fbns client as the socket is still open.

Also, a bit tangential but the keep-alive is hardcoded to 60 seconds on connection and the socket timeout to 30 seconds. Should the socket timeout be higher than the MQTT keep alive? This also means I have to ping really often if I want to avoid timeouts (<30s). I wonder if these timings have been obtained experimentally and whether Instagram will really complain even if the client is not that aggressive? Could we maybe make these parameters configurable on connection?

Affected area

realtime

Minimal reproduction code

cl = Client()
// init client
await cl.fbns_connect()
try:
    await cl.fbns_read_once()
except Exception as e:
    print(f"Got exception {e}, connected={cl.fbns.connected}")

Full traceback

No traceback

Observed result

FBNS client is marked as disconnected on read timeout.

Expected result

FBNS client should stay connected, and only be marked as disconnected when the socket is actually closed.

aiograpi version

1.12.0

Python version

3.14.6

Operating system

7.0.12-1-cachyos

Login method

username/password

Proxy in use

no proxy

Can you reproduce on current main?

yes

Raw API response or payload sample

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions