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

close(code, reason) A parameter or an operation is not supported by the underlying object #158

Open
cgarrovillo opened this issue May 25, 2021 · 1 comment

Comments

@cgarrovillo
Copy link

cgarrovillo commented May 25, 2021

Calling close(code,reason) with arguments throws an error:

Uncaught DOMException: A parameter or an operation is not supported by the underlying object
close reconnecting-websocket-mjs.js:374

Calling close() with no arguments closes the connection just fine.

This is happening when trying to be used in a React component, where the ReconnectingWebSocket object .close() is called on is a reference using React.useRef()

@franky47
Copy link

franky47 commented Dec 7, 2022

What is your value for code?

This error is thrown by the underlying WebSocket when calling close with invalid arguments. If you specify code, it has to be within the 3000-4999 range, and accompanied by a reason string, according to the spec:
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#parameters

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

2 participants