WispFile

WebRTC file transfer, explained

By the WispFile team · Updated 24 September 2026

WebRTC file transfer sends a file directly from one browser to another over an encrypted data channel. A signaling server introduces the two browsers, STUN helps them find a network path through routers, and, if no direct path exists, a TURN server relays the encrypted bytes. The file is split into chunks, sent in order with flow control, and reassembled on the other side.

Key facts

  • Built into every modern browser: no plugin or app.
  • Data channels are always encrypted in transit (DTLS).
  • A server is still needed to introduce the peers, but not to carry the file.
  • The sender must stay online; nothing is stored in between.

The four parts of a WebRTC transfer

PartWhat it doesCarries file data?
SignalingPasses connection offers and network candidates between the two browsersNo
STUNTells a browser its public IP address and port, so it can be reached through a routerNo
TURNRelays traffic when no direct path existsOnly when used, encrypted
Data channelThe direct, encrypted pipe the file travels throughYes

1. Signaling: introducing the browsers

Two browsers cannot find each other on their own. Each one creates a description of how it can connect (an SDP offer or answer) and a list of possible network addresses (ICE candidates). Something has to pass these between them. WebRTC leaves that to the application; WispFile uses a small WebSocket service. It sees that two browsers want to talk, forwards their messages, and never sees the file.

2. NAT traversal: STUN and TURN

Most devices sit behind a router that shares one public address between many devices (NAT). A STUN server answers a simple question: “what address do you see me coming from?” With that, the browsers try to reach each other through their routers, a process called ICE (Interactive Connectivity Establishment, RFC 8445).

When both sides are behind restrictive NATs or firewalls, no direct path works. A TURN server (RFC 8656) then relays the traffic. It passes along encrypted bytes it cannot read, but it does cost bandwidth, which is why many services limit it. On WispFile, free links are direct only and paid plans include a relay.

3. The data channel

Once connected, the browsers open an RTCDataChannel, a message pipe built on SCTP over DTLS. It can be ordered and reliable like TCP, which is what file transfer needs. Two practical details matter:

  • Message size. Browsers cap a single message; the connection advertises its limit (maxMessageSize). WispFile sends files in 256 KB frames and checks the peer’s limit before the first one.
  • Backpressure. A sender that pushes chunks as fast as it can read them fills memory with queued data. The fix is to watch bufferedAmount and wait for the bufferedamountlow event before sending more. Without it, sending a 2 GB file can mean 2 GB of queued messages.

4. Writing to disk on the other side

A received file must not be collected in memory either. Chromium browsers can write straight into a file or folder the user picks (the File System Access API). Other browsers can stream a download through a service worker. Either way, each chunk is written as it arrives, which is what makes multi-gigabyte transfers possible in a browser tab.

Encryption: what DTLS covers and what it does not

DTLS encrypts the data channel between the two endpoints of the connection. If a TURN relay carries the traffic, the relay forwards encrypted packets it cannot read. What DTLS does not protect against is a malicious signaling server, which could in principle introduce itself as the other peer. WispFile closes that gap with a second layer: every chunk is encrypted with AES-GCM under a 256-bit key created in the sender’s browser and placed in the link’s fragment (after the #), which browsers never send to a server. Each chunk also carries a SHA-256 fingerprint that the receiver checks before writing.

What goes wrong, and how to handle it

ProblemCauseFix
Connection never startsBoth networks block direct pathsA TURN relay, or a different network on one side
Transfer stalls at 0%A control message lost while the channel was openingHold early messages and retry requests (fixed in WispFile, found while testing 10 receivers)
Memory climbs with file sizeNo backpressure, or collecting the file in memoryWait on bufferedAmount; stream to disk
Drop mid-transferWi-Fi change, laptop sleepKeep what arrived and ask only for the missing chunks on reconnect

Try it

WispFile is a WebRTC file transfer tool built this way. Open it in two browsers, on two networks if you can, and watch a file cross without being uploaded. For the product-level view, see how WispFile works; for the standard itself, MDN’s WebRTC API documentation and the W3C WebRTC specification.

Frequently asked questions

Is WebRTC file transfer secure?

WebRTC encrypts every data channel with DTLS, so the bytes are encrypted in transit between the two browsers. That protects against eavesdroppers on the network. WispFile adds its own AES-GCM layer on top with a key that only the link carries, so even a relay server in the middle, or a compromised signaling server, cannot read the files.

Does WebRTC work across different networks?

Usually. STUN lets each browser discover its public address so the two can connect through home routers. Some networks (symmetric NATs, strict firewalls) block that; then only a TURN relay can connect them. Estimates of how many connections need a relay commonly range from about 10 to 20%, depending on the networks involved.

Is there a file size limit in WebRTC?

Not for the transfer as a whole. The limit is per message: browsers cap a single data-channel message (commonly around 256 KB). File transfer tools split files into chunks below that size, so a file of any size can be sent as many messages.

Do both browsers need to stay open?

Yes. A WebRTC connection exists only while both pages are open. Closing the sender’s tab ends the transfer; a good implementation lets it resume from where it stopped when both sides are back.

Related guides

Send it directly now

Open WispFile, add your files and share the link. No account, nothing uploaded, nothing stored. Free.

Send files with WispFile