Communication & Background

WebSocket

Probing…

WebSocket is a web platform capability in the Communication & Background category. Bidirectional persistent connection to a server. Supported in Chromium 16+, Firefox 11+, and Safari 7+.

Try it

Loading demo…

Code

const ws = new WebSocket('wss://echo.websocket.events')
ws.onopen = () => ws.send('hello')
ws.onmessage = e => console.log('echo', e.data)
ws.onerror = () => console.warn('needs a reachable server')
// later
ws.close()

Browser support

Chromium
16
Firefox
11
Safari
7

Frequently asked questions

Which browsers support WebSocket?

Supported in Chromium 16+, Firefox 11+, and Safari 7+.

Does WebSocket require HTTPS?

No. WebSocket works without a secure context, though serving your site over HTTPS is always recommended.

What is WebSocket used for?

Bidirectional persistent connection to a server.

Can I try WebSocket in my browser?

Yes. shwcs.net runs a live WebSocket demo that probes your current browser and lets you try the API. Everything runs locally — nothing is sent anywhere.

MDN reference ↗ Specification ↗