Version: 9.4.30.v20200611 |

Chapter 26. WebSocket Introduction
Previous | Part IV. Jetty Development Guide Home | Next

##### Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

## Chapter 26. WebSocket Introduction

WebSocket is a new protocol for bidirectional communications initiated via HTTP/1.1 upgrade and providing basic message framing, layered over TCP. It is based on a low-level framing protocol that delivers messages in either UTF-8 TEXT or BINARY format.

A single message in WebSocket can be of any size (the underlying framing however does have a single frame limit of 63-bits). There can be an unlimited number of messages sent. Messages are sent sequentially, the base protocol does not support interleaved messages.

A WebSocket connection goes through some basic state changes:

Table 26.1. WebSocket connection states

State | Description
--- | ---
CONNECTING | A HTTP Upgrade to WebSocket is in progress
OPEN | The HTTP Upgrade succeeded and the socket is now open and ready to read / write
CLOSING | A WebSocket Close Handshake has been started
CLOSED | WebSocket is now closed, no more read/write possible

When a WebSocket is closed, a status code and short reason string is provided.

## What Jetty provides

Jetty provides an implementation of the following standards and specs.

RFC-6455

  The WebSocket Protocol

  We support the version 13 of the released and final spec.

  Jetty tests its WebSocket protocol implementation using the autobahn testsuite.

> ### Important

> The early drafts of WebSocket were supported in Jetty 7 and Jetty 8, but this support has been removed in Jetty 9. This means that Jetty 9 will not support the old browsers that implemented the early drafts of WebSocket. (such as Safari 5.0 or Opera 12)

> ### Tip

> Want to know if the browser you are targeting supports WebSocket? Use caniuse.com/websockets to find out.

JSR-356

  The Java WebSocket API (`javax.websocket`)

  This is the official Java API for working with WebSockets.

Unstable standards and specs:

perframe-compression

  Per Frame Compression Extension.

  An early extension draft from the Google/Chromium team that would provide WebSocket frame compression. perframe-compression using deflate algorithm is present on many versions of Chrome/Chromium.

  Jetty’s support for perframe-compression is based on the draft-04 spec. This standard is being replaced with permessage-compression.

permessage-compression

  Per Frame Compression Extension.

  This is the replacement for perframe-compression, switching the compression to being based on the entire message, not the individual frames.

Previous | Top | Next
Chapter 25. Handlers | Home | WebSocket APIs

See an error or something missing? Contribute to this documentation at Github!(Generated: 2020-06-11)