Closed morgz closed 2 years ago
The client will continue attempting reconnects on a stepped backoff strategy.
The BasicChat Example provides an example of this behavior
You can give your own backoff strategy if you'd like.
// Socket.swift
public var reconnectAfter: (Int) -> TimeInterval = Defaults.reconnectSteppedBackOff
socket.reconnetAfter = { (tries) ->
// Return seconds to wait before reconnecting
}
Thanks Dan. I'm just debugging why my code doesn't adopt this default behaviour as I've pretty much used the code straight from the sample. I'll report back. My sequence of events are:
LOG: SwiftPhoenixClient: transport, close
LOG: SwiftPhoenixClient: channel, error topic: conversation:6a42f5c4-8220-4899-a49c-21d206633641 joinRef: 6 mesage: SwiftPhoenixClient.Message
LOG: SwiftPhoenixClient: Socket reconnecting in 0.01s
MY_APP: Socket Closed
LOG: SwiftPhoenixClient: Socket attempting to reconnect
MY_APP: Socket Closed
LOG: SwiftPhoenixClient: transport, WSError(type: Starscream.ErrorType.upgradeError, message: "Invalid HTTP upgrade", code: 502)
MY_APP: Socket Errored. WSError(type: Starscream.ErrorType.upgradeError, message: "Invalid HTTP upgrade", code: 502)
LOG: SwiftPhoenixClient: transport, close
MY_APP: Socket Closed
OK it appears to work fine when connecting straight to localhost. It doesn't work as expected when tunnelling to localhost via ngrok.
What is the defined behaviour when the remote server closes the connection? e.g. I kill my dev server and then start it again.
I guess I was expecting the client to automatically reconnect if the restart happens within a window of 30 seconds or something like that.