Re: [Uri-review] [hybi] ws: and wss: schemes

Jamie Lokier <jamie@shareable.org> Thu, 10 September 2009 22:41 UTC

Return-Path: <jamie@shareable.org>
X-Original-To: uri-review@core3.amsl.com
Delivered-To: uri-review@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id A6B643A6861; Thu, 10 Sep 2009 15:41:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.621
X-Spam-Level:
X-Spam-Status: No, score=-3.621 tagged_above=-999 required=5 tests=[AWL=-1.322, BAYES_00=-2.599, MIME_8BIT_HEADER=0.3]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VgzgBVLMejg4; Thu, 10 Sep 2009 15:41:23 -0700 (PDT)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id BDFB93A67E7; Thu, 10 Sep 2009 15:41:23 -0700 (PDT)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1MlsKt-0004i1-1O; Thu, 10 Sep 2009 23:41:51 +0100
Date: Thu, 10 Sep 2009 23:41:51 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Křištof Želechovski <giecrilj@stegny.2a.pl>
Message-ID: <20090910224151.GA17387@shareable.org>
References: <Pine.LNX.4.62.0908070531430.28566@hixie.dreamhostps.com> <1249651007.25446.8934.camel@dbooth-laptop> <0B450D619CC0486E8BD51C31FBA214AD@POCZTOWIEC> <20090812021926.GC19298@shareable.org> <AB9A0CF094F04D39BC7DC5DEAFF7FC1C@POCZTOWIEC> <4AA8A2CE.3000801@it.aoyama.ac.jp> <34660A8503164BE88641374ADF2BF1A3@POCZTOWIEC> <20090910124618.GB32178@shareable.org> <11DFA16908CB4B7D8AF0F45975DE425A@POCZTOWIEC>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <11DFA16908CB4B7D8AF0F45975DE425A@POCZTOWIEC>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: hybi@ietf.org, uri-review@ietf.org, uri@w3.org
Subject: Re: [Uri-review] [hybi] ws: and wss: schemes
X-BeenThere: uri-review@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Proposed URI Schemes <uri-review.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/uri-review>, <mailto:uri-review-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/uri-review>
List-Post: <mailto:uri-review@ietf.org>
List-Help: <mailto:uri-review-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/uri-review>, <mailto:uri-review-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Sep 2009 22:41:24 -0000

Křištof Želechovski wrote:
> AIUI, in order to provide a service over WebSockets, you have to
> implement it in raw stream first.  This stream, once implemented,
> can run quite happily under tcpd, and the WebSockets shim is only a
> wrapper.

All those points are false, so the rest of your argument falls apart.

You seem to think WebSockets is a wrapper around a two-way raw byte
stream, but it isn't.  In fact it's quite tricky to transport a raw
byte stream over WebSockets, and you'd have to define your own
protocol on top of WebSockets to do it.

WebSockets provides application-visible framing with NUL-terminated
UTF-8 strings.  (I haven't checked what it does if you have a real NUL
character to transmit - does the spec say?).  You cannot transmit
binary data in those UTF-8 string frames, or even arbitrary non-zero
bytes; they must be valid UTF-8.

Although the protocol has binary frames and room for other frame
types, Javascript browser implementations will not support them for a
long time if ever, therefore binary is not practical to use.  You can
of course encode binary data to UTF-8 strings, but your encoding would
be application-specific.

The framing is explicit; it cannot be altered in transit (unlike TCP),
is visible to applications, and was intentionally designed to map to
Javascript DOM events - one event per UTF-8 frame.  Applications are
very likely to be coded around that assumption.  (Even if binary
frames ever get supported, this differentiates it from a raw stream.)

So, no, you would not code a WebSockets service by writing a raw
stream protocol first and then using WebSockets as a shim.  It would
be a very complicated way to do it.

You would only do that, if you _already_ have a raw stream protocol,
but you'd still need an additional layer for binary-to-UTF-8 encoding
and packetising, of your own design, on top of WebSockets.

> So there is one protocol and one implementation thereof,
> only exposed over two different transport channels.

If that were true (it's not), you'd still need to write non-browser
things which talk to other people's services over WebSockets, in order
to access services that are only offered over one channel because they
don't care to provide the other one.

By the way, I have argued in favour of WebSockets being more like a
raw stream to applications (mostly for efficiency reasons but the shim
argument you've given is also a good one), so I'm only describing what
it is and what consequences to expect, not saying I like it.

-- Jamie