Skip to content

instameow: reconnect backoff parity with messagix, and a Connect lock for the Instagram client - #320

Open
aminebalti55 wants to merge 2 commits into
mautrix:mainfrom
aminebalti55:pr/instagram-reconnect-parity
Open

instameow: reconnect backoff parity with messagix, and a Connect lock for the Instagram client#320
aminebalti55 wants to merge 2 commits into
mautrix:mainfrom
aminebalti55:pr/instagram-reconnect-parity

Conversation

@aminebalti55

Copy link
Copy Markdown

Two small fixes that bring the Instagram connector in line with behaviour the Messenger connector already has.

instameow: only reconnect immediately after a stable connection

Both Instagram sockets (socket.go, streamcontroller.go) reset their backoff and reconnected with no delay whenever the previous connection had been marked connected at any point, however briefly. A connection that is accepted, subscribed and dropped again within seconds therefore produced an un-backed-off hot loop against the gateway.

messagix/client.go:461 already handles this — it only grants an immediate reconnect once the connection has held for two minutes. This applies the same rule to the Instagram sockets, and adds ±20% jitter to the exponential backoff so that many logins failing at once don't retry in lockstep.

igconnector: guard Connect against parallel invocation

MetaClient.Connect refuses to run twice at once via connectLock.TryLock(); IGClient.Connect had no equivalent. Two overlapping calls shared one instameow.Client and ran two index-load flows against the same account with the same cookies simultaneously. Mirrors the existing guard exactly.

Both build and go vet clean; each commit is self-contained.

The socket loops reset their backoff and reconnected with no delay whenever
the previous connection had been marked connected at any point, however
briefly. A connection that is accepted, subscribed and dropped again within
seconds therefore produced an un-backed-off hot loop against the gateway -
the opposite of what a soft refusal should be met with.

The messagix client already handles this: it only grants an immediate
reconnect once the connection has held for two minutes. Apply the same rule
to both Instagram sockets, and add +-20% jitter to the exponential backoff so
that many logins failing at once do not retry in lockstep for good.
MetaClient.Connect refuses to run twice at once via connectLock.TryLock; the
Instagram client had no equivalent. Two overlapping Connect calls shared one
instameow.Client and ran two index-load flows against the same account with
the same cookies simultaneously - which is what a second-device login looks
like from the other side. Mirror the existing guard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant