websockets provides newClientConnection as an alternative to the bracket-style functions. It allows the app to take responsibility for managing/cleaning up the connection by separating the connection and the clientApp. I’m proposing we add the corresponding secure version:
newSecureClientConnection
:: Socket.Host -- ^ Host
-> Socket.PortNumber -- ^ Port
-> String.String -- ^ Path
-> Config -- ^ Config
-> WebSockets.ConnectionOptions -- ^ Options
-> WebSockets.Headers -- ^ Headers
-> IO.IO (WebSockets.Connection)
Use cases
Timeout
Currently, the initial connection will hang indefinitely if the server is unresponsive. With newSecureClientConnection, we can add a timeout just for the connection and handshake.
import qualified System.Timeout as Timeout
maybeConnection <- Timeout.timeout 5_000_000 $ newSecureClientConnection ...
Related issues:
jaspervdj/websockets#229
Retry
The retry package doesn’t play well with websockets. The retry counter is designed to reset when the inner function returns, but a websocket doesn’t return once successfully connected. For example, if you use exponential backoff, the backoff will keep increasing every time the connection drops, even with successful connections in between.
With newSecureClientConnection, we can at least handle an unresponsive server by wrapping the connection in a retry. Errors from the clientApp would have to be handled separately.
Related issues:
Soostone/retry#25
#18
Alternatives
The alternative would be to manage the connection manually, without Wuss.
Would there be interest in adding this? Any thoughts?
websocketsprovidesnewClientConnectionas an alternative to the bracket-style functions. It allows the app to take responsibility for managing/cleaning up the connection by separating the connection and theclientApp. I’m proposing we add the corresponding secure version:Use cases
Timeout
Currently, the initial connection will hang indefinitely if the server is unresponsive. With
newSecureClientConnection, we can add a timeout just for the connection and handshake.Related issues:
jaspervdj/websockets#229
Retry
The
retrypackage doesn’t play well with websockets. The retry counter is designed to reset when the inner function returns, but a websocket doesn’t return once successfully connected. For example, if you use exponential backoff, the backoff will keep increasing every time the connection drops, even with successful connections in between.With
newSecureClientConnection, we can at least handle an unresponsive server by wrapping the connection in a retry. Errors from theclientAppwould have to be handled separately.Related issues:
Soostone/retry#25
#18
Alternatives
The alternative would be to manage the connection manually, without Wuss.
Would there be interest in adding this? Any thoughts?