autobahn-js
autobahn-js copied to clipboard
proxy worker intermittent connection error results in will_retry: false
Screenshot: https://i.gyazo.com/53bfb2180160e7d86cbee38f40683cef.png
This wamp client uses the default anonymous auth, so its confusing how that could fail? Even more confusing is how it sometimes succeeds, and sometimes fails. I suspect this is due to proxy workers being a work in progress?
will_retry: false is pretty annoying, because i want my clients to always retry, regardless of the disconnection reason. I was under the impression that setting max_retries: -1
would force clients to always retry, but if will_retry is false then my client stays disconnected, which is highly undesirable. As a workaround I manually reconnect in the onclose callback if will_retry is false.
We have the same issue, and wrapped the connection in our own connection, in the same manner. Needed this to be fixed. Can we provide a PR?
@guanzo Would you mind sharing how did you actually do on onClose ? Can you share the code ?
@berTrindade something like this
connect () {
return new Promise(resolve => {
const conn = this.connection
if (conn?.isConnected && conn?.isOpen) {
resolve()
return
}
const autobahnOpts = {
initial_retry_delay: 5,
}
const onOpen = async (session) => {
this.session = session
try {
await this._registerProcedures(session)
} catch (e) {
debug(e)
// TODO: Retry registrations?
}
debug('wamp session opened')
resolve()
}
const onClose = (reason, details) => {
debug('wamp session closed', reason, details)
resolve() // resolve even if error, autobahn will retry.
// Force autobahn to always retry.
if (!details.will_retry) {
debug('will_retry is false, manually reconnecting')
clearTimeout(this.retryTimeoutId)
this.retryTimeoutId = setTimeout(() => this.connect(), 5000)
}
}
this.connection = baseConnectToRouter(onOpen, onClose, autobahnOpts)
})
}
Thanks, @guanzo! Btw, just sent you a LinkedIn connect invite.