Jetty Logo
Version: 9.2.7-SNAPSHOT
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 from 1 day to full product delivery

Chapter 29. WebSocket Introduction

Table of Contents

What Jetty provides
WebSocket APIs

WebSocket is a new protocol for bidirectional communications over HTTP.

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 29.1. WebSocket connection states

StateDescription
CONNECTINGA HTTP Upgrade to WebSocket is in progress
OPENThe HTTP Upgrade succeeded and the socket is now open and ready to read / write
CLOSINGA WebSocket Close Handshake has been started
CLOSEDWebSocket 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.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2014-12-21T01:00:34-08:00)