Reconnect when the websocket closes
kumamoto opened this issue · comments
kumamoto commented
What's the recommended way of reconnecting once the ws has closed (timeout)
Simon Binder commented
Do you mean with drift or with the raw hrana
package? I don't think we can transparently recover from that yet, I'd just re-open the database.
In package:hrana
version 0.2.0, you can use the closed
getter on Database
to obtain a future that resolves as soon as the database connection is closed, regardless of whether that was due to a close()
call or because of a timeout/the server going down. So you can whenComplete
that future to add a callback to run when that happens and re-open the database if necessary.