files/en-us/web/api/webtransport/close/index.md
{{APIRef("WebTransport API")}}{{SecureContext_Header}} {{AvailableInWorkers}}
The close() method of the {{domxref("WebTransport")}} interface closes an ongoing WebTransport session.
close(info)
info {{optional_inline}}
closeCode
reason
WebTransport.undefined.
close() is invoked while the WebTransport is in the process of connecting.const url = "https://example.com:4999/wt";
// Initialize transport connection
const transport = new WebTransport(url);
// …
transport.close({
closeCode: 17,
reason: "CloseButtonPressed",
});
{{Specifications}}
{{Compat}}