Re: [hybi] Multiplexing in WebSocket (Was: HyBi Design Space)

Greg Wilkins <gregw@webtide.com> Mon, 12 October 2009 21:07 UTC

Return-Path: <gregw@webtide.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 7123728C20B for <hybi@core3.amsl.com>; Mon, 12 Oct 2009 14:07:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.679
X-Spam-Level:
X-Spam-Status: No, score=-0.679 tagged_above=-999 required=5 tests=[AWL=1.920, BAYES_00=-2.599]
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 ndLGJzPiQrKa for <hybi@core3.amsl.com>; Mon, 12 Oct 2009 14:07:01 -0700 (PDT)
Received: from mail-fx0-f228.google.com (mail-fx0-f228.google.com [209.85.220.228]) by core3.amsl.com (Postfix) with ESMTP id 2EB9928C1B1 for <hybi@ietf.org>; Mon, 12 Oct 2009 14:07:00 -0700 (PDT)
Received: by fxm28 with SMTP id 28so7869043fxm.42 for <hybi@ietf.org>; Mon, 12 Oct 2009 14:06:58 -0700 (PDT)
Received: by 10.86.242.15 with SMTP id p15mr5610628fgh.14.1255381618777; Mon, 12 Oct 2009 14:06:58 -0700 (PDT)
Received: from ?10.10.1.9? (60-242-119-126.tpgi.com.au [60.242.119.126]) by mx.google.com with ESMTPS id 4sm162871fge.2.2009.10.12.14.06.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 12 Oct 2009 14:06:57 -0700 (PDT)
Message-ID: <4AD39A64.4080405@webtide.com>
Date: Tue, 13 Oct 2009 08:06:44 +1100
From: Greg Wilkins <gregw@webtide.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To: Graham Klyne <gk-ietf-hybi@ninebynine.org>
References: <4ACE50A2.5070404@ericsson.com> <3a880e2c0910081600v3607665dp193f6df499706810@mail.gmail.com> <4ACF4055.6080302@ericsson.com> <Pine.LNX.4.62.0910092116010.21884@hixie.dreamhostps.com> <4AD2E353.8070609@webtide.com> <4AD2F43D.6030202@ninebynine.org>
In-Reply-To: <4AD2F43D.6030202@ninebynine.org>
X-Enigmail-Version: 0.95.7
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] Multiplexing in WebSocket (Was: HyBi Design Space)
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 12 Oct 2009 21:07:02 -0000

Graham Klyne wrote:
> To add just one voice among many...
> 
> (1) in the use-cases that I've considered for pushing messages/requests
> to a browser, multiplexing is not a requirement.  Other's mileage may,
> of course, vary.

Graham, it would be great if you could briefly describe
your use-cases.

Are you sure that they will never be mashed up into a webapp made
of many parts that originally were not designed to work together?

Are you sure that they would never run behind a transparent proxy
that might aggregate multiple connections into a single connection?


> (2) Looking at a multiplexing protocol such as BEEP, multiplexing adds a
> *lot* of complexity to the protocol specification and implementation.  I
> would say that the case for multiplexing in the base protocol needs to
> be made to justify that added complexity.

I totally agree that the multiplexing of BEEP is too complex for
the level of protocol that we are considering.

But multiplexing can be much much simpler.  At it simplest,
it just needs a channel id in each frame and the channel creation
can be automatic.   In the BWTP protocol proposal, I've added
a little bit of channel creation exchange, so as to well match
the explicit life cycle events of the websocket API.

> (3) It seems to me that, if needed, a multiplexing layer could be
> specified and standardized over a non-multiplexing substrate.

Normally I do believe layering protocols like you describe would be
a good approach. But...

The difficulty is that with websocket protocol, it has a hard binding
to the application websocket API.  There is no scope provided to inject
another layer.   The API has explicit  open/close events (which I think
should be mapped to channels), but that are currently mapped to connections.
Thus applications and/or frameworks will be doing explicit connection
management.

This is analogous to the advent of XHR in the browser. Every Ajax
books then started with a chapter about how to write your own Ajax
code directly using XHR.  But XHR is a too low level API for
applications and it has taken many years to abstract the average
ajax developer away from direct XHR access.  So now we have
frameworks such as dojo, jquery, yahoo, ext etc that provide an
abstraction on top of XHR.

Probably these frameworks will be able to provide good abstractions
on top of websocket API, and this may well include multiplexing
support.   But even if the frameworks implemented to same wire
protocol for multiplexing, they would not be able to:

  + share connections between frameworks
  + share connections with code written directly to the websocket API.
  + share connections with other iframes, tabs and/or windows.
  + implement a strong origin policy for security


I believe that these desirable things can only be achieved if
it is the browser rather than the application that implements
the multi-plexing.

The fundamental problem with websocket API is that is both
a connection API (open/close) and a messaging API (send/onMessage).
The API needs to be abstracted away from any hard relationship
to TCP/IP connections.   This can be done with a simple rename
of s/connection/channel/.     Applications can then manage channels
and the browser/server can manage mapping those channels to
connections - perhaps with multiplexing or perhaps without.


cheers