ws-connect retries multiple times
Using websocket like
<div hx-ext="ws" ws-connect="/ws/attempt/{{ id }}/" hx-trigger="load"></div>
However, it retries n number of times when the connection is failing.
Accordingly to my use case, I do not want the connection to reconnect or retry only once. Also in the development server, I want to completely disable retrying.
How can I do it?
By default it uses an exponential backoff algorithm, in the docs it also says you can use your own https://htmx.org/extensions/web-sockets/ Under the "Automatic Reconnection" header. If you make the delay function something like
htmx.config.wsReconnectDelay = function (retryCount) {
return 1000000000 // retry in 1 million seconds
}
Hope this solves your problem
@itepastra Thanks for the suggestion. However, it will still retry after 1 million seconds. I understand that this is a large value and no session can be alive for this long time. Isn't there a way to completely disable retrying or can add this feature?
Removing the following should keep htmx from retrying. If you download the ws.js file and host the modified version locally you can test it. https://github.com/bigskysoftware/htmx/blob/master/src%2Fext%2Fws.js#L261-L267