Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy worker intermittent connection error results in will_retry: false #528

Open
guanzo opened this issue Aug 16, 2020 · 4 comments
Open

Comments

@guanzo
Copy link

guanzo commented Aug 16, 2020

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.

@guanzo guanzo changed the title proxy worker connection error results in will_retry: false proxy worker intermittent connection error results in will_retry: false Aug 16, 2020
@TeodorAndersson
Copy link

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?

@berTrindade
Copy link

@guanzo Would you mind sharing how did you actually do on onClose ? Can you share the code ?

@guanzo
Copy link
Author

guanzo commented May 14, 2023

@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)
        })
    }

@berTrindade
Copy link

Thanks, @guanzo! Btw, just sent you a LinkedIn connect invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants