We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE


This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The RTCPeerConnection.close() method closes the current peer connection.



This method has no parameters, and returns nothing.

Calling this method terminates the RTCPeerConnection's ICE agent, ending any ongoing ICE processing and any active streams. This also releases any resources in use by the ICE agent, including TURN permissions. All RTCRtpSender objects are considered to be stopped once this returns (they may still be in the process of stopping, but for all intents and purposes, they're stopped).

Once this method returns, the signaling state as returned by RTCPeerConnection.signalingState is closed.


var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");

dc.onmessage = function (event) {
  console.log("received: " + event.data);
  pc.close(); // We decided to close after the first received message

dc.onopen = function () {
  console.log("datachannel open");

dc.onclose = function () {
  console.log("datachannel close");


Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.close()' in that specification.
Candidate Recommendation Initial specification.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes)[1] (Yes) 22 (22) [2] No support (Yes) ?
Feature Android Webview Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes)[1] (Yes)[1] (Yes) 22 (22) [2] No support ? ?

[1] Though this method is not prefixed, the interface it belongs to was until Chrome 56.

[2] Though this method is not prefixed, the interface it belongs to is, until Firefox 44.

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, abbycar, Sheppy, teoli, mikeg0
 Last updated by: jpmedley,