instameow: reconnect backoff parity with messagix, and a Connect lock for the Instagram client - #320
Open
aminebalti55 wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:461already 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.Connectrefuses to run twice at once viaconnectLock.TryLock();IGClient.Connecthad no equivalent. Two overlapping calls shared oneinstameow.Clientand ran two index-load flows against the same account with the same cookies simultaneously. Mirrors the existing guard exactly.Both build and
go vetclean; each commit is self-contained.