Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api.go to implement websocket retry #187

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions imessage/bluebubbles/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ func (bb *blueBubbles) PollForWebsocketMessages() {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
bb.log.Error().Err(err).Msg("Error reading message from BlueBubbles websocket")
}
bb.log.Info().Msg("Attempting to reconnect to BlueBubbles websocket...")
err = bb.retryConnect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing the retryConnect function anywhere, do you have to make one?

  • I think you should probably do everything in lines 87-97 in retryConnect, the initial handshake is important
  • also would be a good idea to bake in a 5-10 sec sleep and Max retries. if the BB URL changes, which it does often, you don't want this looping aggressively forever

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cnuss we are actually talking about this in the mautrix-imessage channel already. ChatGPT just hallucinated on @rollingonchrome

if err != nil {
bb.log.Error().Err(err).Msg("Failed to reconnect to BlueBubbles websocket")
break
}
continue
}

if bytes.Equal(payload, []byte("2")) {
Expand Down
Loading