WebTransport: close() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The close()
method of the WebTransport
interface closes an ongoing WebTransport session.
Syntax
js
close(info)
Parameters
info
Optional-
An object containing the following properties:
Return value
undefined
.
Exceptions
WebTransportError
-
Thrown if
close()
is invoked while the WebTransport is in the process of connecting.
Examples
js
const url = "https://example.com:4999/wt";
// Initialize transport connection
const transport = new WebTransport(url);
// ...
transport.close({
closeCode: 017,
reason: "CloseButtonPressed",
});
Specifications
Specification |
---|
WebTransport # dom-webtransport-close |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
close |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.