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

retryOnError does not retry if share is true and shouldReconnect is not specified #209

Open
dan-sherwin opened this issue Sep 29, 2023 · 0 comments

Comments

@dan-sherwin
Copy link

    const { } = useWebSocket("wss://Imateapot.org",{
        share: true,
        retryOnError: true,
        reconnectAttempts: 3,
        reconnectInterval: 1000,
        onOpen: e=>console.log("ONOPEN", e),
        onClose: e=>console.log("ONCLOSE", e),
        onMessage: e=>console.log("ONMESSAGE", e),
        onError: e=>console.log("ONERROR", e),
        onReconnectStop: e=>console.log("ONRECONNECTSTOP", e),
    },true);

Using the example above, it will not attempt to retry the connection on connection failure. If you set share to false, it will attempt to retry the connection for the set number of attempts. If you set share to true, and specify shouldReconnect: ()=>true then it will retry the connection as well.

I would expect that it should retry the connection as my example shows, should it not?

You can test it here: CodeSandbox

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

No branches or pull requests

1 participant