Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3a60239e2436660f6acd43928b60bbd0d5c563c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Chapter&nbsp;30.&nbsp;WebSocket Introduction</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, spdy, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="development.html" title="Part&nbsp;IV.&nbsp;Jetty Development Guide"><link rel="prev" href="http-client-other.html" title="Other Features"><link rel="next" href="ws-intro-api.html" title="WebSocket APIs"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small">
            Version: 9.2.2-SNAPSHOT</span></td><td style="width: 50%"><script type="text/javascript">  (function() {
            var cx = '016459005284625897022:obd4lsai2ds';
            var gcse = document.createElement('script');
            gcse.type = 'text/javascript';
            gcse.async = true;
            gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//www.google.com/cse/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(gcse, s);
            })();
          </script><gcse:search></gcse:search></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;30.&nbsp;WebSocket Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="http-client-other.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;IV.&nbsp;Jetty Development Guide<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ws-intro-api.html">Next <i class="icon-chevron-right"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at
          <span class="website">www.webtide.com</span></a></h5><p>
 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
      </p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="websocket-intro"></a>Chapter&nbsp;30.&nbsp;WebSocket Introduction</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="websocket-intro.html#ws-intro-provides">What Jetty provides</a></span></dt><dt><span class="section"><a href="ws-intro-api.html">WebSocket APIs</a></span></dt></dl></div><p>WebSocket is a new protocol for bidirectional communications over
  HTTP.</p><p>It is based on a low level framing protocol that delivers messages in
  either UTF-8 TEXT or BINARY format.</p><p>A single message in WebSocket can be of any size (the underlying
  framing however does have a single frame limit of <a class="link" href="http://en.wikipedia.org/wiki/9223372036854775807" target="_top">63-bits</a>)</p><p>There can be an unlimited number of messages sent.</p><p>Messages are sent sequentially, the base protocol does not support
  interleaved messages.</p><p>A WebSocket connection goes through some basic state changes:</p><div class="table"><a name="d0e21522"></a><p class="title"><b>Table&nbsp;30.1.&nbsp;WebSocket connection states</b></p><div class="table-contents"><table summary="WebSocket connection states" border="1"><colgroup><col width="20%" align="center"><col></colgroup><thead><tr><th align="center">State</th><th align="center">Description</th></tr></thead><tbody><tr><td align="center">CONNECTING</td><td>A HTTP Upgrade to WebSocket is in progress</td></tr><tr><td align="center">OPEN</td><td>The HTTP Upgrade succeeded and the socket is now open and
          ready to read / write</td></tr><tr><td align="center">CLOSING</td><td>A WebSocket Close Handshake has been started</td></tr><tr><td align="center">CLOSED</td><td>WebSocket is now closed, no more read/write possible</td></tr></tbody></table></div></div><br class="table-break"><p>When a WebSocket is closed, a <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/websocket/api/StatusCode.html" target="_top">status
  code</a> and short reason string is provided.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ws-intro-provides"></a>What Jetty provides</h2></div></div></div><p>Jetty provides an implementation of the following standards and
    specs.</p><div class="variablelist"><dl><dt><span class="term"><a class="link" href="http://tools.ietf.org/html/rfc6455" target="_top">RFC-6455</a></span></dt><dd><p>The WebSocket Protocol</p><p>We support the version 13 of the released and final
          spec.</p><p>Jetty tests its WebSocket protocol implementation using the
          <a class="link" href="http://autobahn.ws/testsuite" target="_top">autobahn
          testsuite</a>.</p><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="icon-plus-sign-alt"></i> Important</h3><p>The early drafts of WebSocket were supported in Jetty 7 and
            Jetty 8, but this support has been removed in Jetty 9. </p><p>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)</p></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="icon-lightbulb"></i> Tip</h3><p>Want to know if the browser you are targeting supports
            WebSocket?</p><p>Use <a class="link" href="http://caniuse.com/websockets" target="_top">caniuse.com/websockets</a>
            to find out.</p></div></dd><dt><span class="term"><a class="link" href="http://www.jcp.org/en/jsr/detail?id=356" target="_top">JSR-356</a></span></dt><dd><p>The Java WebSocket API
          (<code class="classname">javax.websocket</code>)</p><p>This is the official Java API for working with
          WebSockets.</p></dd></dl></div><p>Unstable standards and specs:</p><div class="variablelist"><dl><dt><span class="term"><a class="link" href="https://datatracker.ietf.org/doc/draft-ietf-hybi-websocket-perframe-compression/" target="_top">perframe-compression</a></span></dt><dd><p>Per Frame Compression Extension.</p><p>An early extension draft from the Google/Chromium team that
          would provide WebSocket frame compression.</p><p>perframe-compression using deflate algorithm is present on
          many versions of Chrome/Chromium.</p><p>Jetty's support for perframe-compression is based on the
          draft-04 spec.</p><p>This standard is being replaced with
          permessage-compression.</p></dd><dt><span class="term"><a class="link" href="https://datatracker.ietf.org/doc/draft-tyoshino-hybi-permessage-compression/" target="_top">permessage-compression</a></span></dt><dd><p>Per Frame Compression Extension.</p><p>This is the replacement for perframe-compression, switching
          the compression to being based on the entire message, not the
          individual frames.</p></dd></dl></div></div></div><script type="text/javascript">
      SyntaxHighlighter.all()
    </script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="http-client-other.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="development.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ws-intro-api.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Other Features&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;WebSocket APIs</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout">
            See an error or something missing?
            <span class="callout"><a href="http://github.com/jetty-project/jetty-documentation">Contribute to this documentation at
                <span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2014-09-16T01:00:32-07:00)</i></span></div></p><script xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1149868-7']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
    </script></body></html>

Back to the top