Re: [hybi] Multiplexing in WebSocket
Ian Hickson <ian@hixie.ch> Tue, 27 October 2009 02:03 UTC
Return-Path: <ian@hixie.ch>
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 23DB63A6824 for <hybi@core3.amsl.com>; Mon, 26 Oct 2009 19:03:46 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.4
X-Spam-Level:
X-Spam-Status: No, score=-2.4 tagged_above=-999 required=5 tests=[AWL=-0.116, BAYES_00=-2.599, SARE_MILLIONSOF=0.315]
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 MT6qImMhO2K0 for <hybi@core3.amsl.com>; Mon, 26 Oct 2009 19:03:44 -0700 (PDT)
Received: from looneymail-a1.g.dreamhost.com (caibbdcaaaaf.dreamhost.com [208.113.200.5]) by core3.amsl.com (Postfix) with ESMTP id D6F0E3A67FF for <hybi@ietf.org>; Mon, 26 Oct 2009 19:03:44 -0700 (PDT)
Received: from hixie.dreamhostps.com (hixie.dreamhost.com [208.113.210.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by looneymail-a1.g.dreamhost.com (Postfix) with ESMTP id 009F015D7CF; Mon, 26 Oct 2009 19:03:56 -0700 (PDT)
Date: Tue, 27 Oct 2009 02:04:05 +0000
From: Ian Hickson <ian@hixie.ch>
To: Greg Wilkins <gregw@webtide.com>
In-Reply-To: <4AE4119A.7040803@webtide.com>
Message-ID: <Pine.LNX.4.62.0910270130580.9145@hixie.dreamhostps.com>
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> <4AD39A64.4080405@webtide.com> <Pine.LNX.4.62.0910132335390.25383@hixie.dreamhostps.com> <4AD53DCA.6050304@webtide.com> <Pine.LNX.4.62.0910170203460.9145@hixie.dreamhostps.com> <4ADA7FD4.9010406@webtide.com> <4ADB6F0B.4000004@gmail.com> <Pine.LNX.4.62.0910221120380.9145@hixie.dreamhostps.com> <4AE08907.7080402@webtide.com> <Pine.LNX.4.62.0910230348470.9145@hixie.dreamhostps.com> <4AE1E659.5050507@webtide.com> <Pine.LNX.4.62.0910232154470.13521@hixie.dreamhostps.com> <4AE23D7A.2060009@webtide.com> <Pine.LNX.4.62.0910240926500.9145@hixie.dreamhostps.com> <4AE4119A.7040803@webtide.com>
Content-Language: en-GB-hixie
Content-Style-Type: text/css
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset="US-ASCII"
Cc: hybi@ietf.org
Subject: Re: [hybi] Multiplexing in WebSocket
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: Tue, 27 Oct 2009 02:03:46 -0000
On Sun, 25 Oct 2009, Greg Wilkins wrote: > > > > The main difference is that most people won't manage UTF-8 encoding. > > In Perl, for instance, there's the "Encode" library that you can just > > pass byte strings to to have them converted into UTF-8, and > > vice-versa. > > Forgive my total lack of knowledge of perl, but given the availability > of the encode library in perl, I see little difference in the complexity > of sentinel marked code which is: > > $octets = encode("utf-8", $message) > write ($octets) > write (oxff) > > versus length encoding code which is > > $octets = encode("utf-8", $message) > write ($octets.length) > write ($octets) Yup, in Perl, once you have encoded the string correctly, getting the lenght is relatively easy. However, I expect many people won't be explicitly encoding the string at all; they'll just output the string straight to the socket and have the socket encode the UTF-8. Many servers don't need to know what is going on, since they can just be opaque to most of the data and just use ASCII for the "command" part of their API. > They will need a method to correctly encode the length as an unlimited > integer, but they will probably need that anyway as you currently > specify that length encoded framing is part of the standard (stacked > out). They only need to support that if they will be using the binary part of the protocol. > > We have binary frames already staked out in the protocol, waiting for > > support in JS for binary. > > I don't see why an IETF protocol proposal needs to wait for the js > implementation? The only reason this protocol exists is for the JS API. If it wasn't for the JS API's requirements, TCP itself already addresses the needs. > Since the binary framing is about the same level of complexity, is more > capable and is already stacked out - they why not avoid the complexity > to two different framings and just use length? Getting the length of strings is non-trivial in many environments (certainly compared to getting the length of binary data). Most servers will never have to deal with the binary stuff at all. And you're much more likely to have buffer overrun bugs if you use a length prefix followed by a variable-length encoding of text. > JS is free to limit it's usage to just utf-8 as long as it likes. But > JS is not the only client language that is going to use an IETF > sanctioned bidirectional protocol. I sure hope nobody is hoping to use WebSocket with anything other than JS -- it's be a complete waste of time to use WebSocket for anything if we're just talking about an arbitrary client-server protocol. We already have TCP for people who want to write their own subprotocol, and we already have BEEP, Jabber, and a multitude of other transports for people who want a more structured protocol to tunnel over. Now, granted, some people might want to speak to WebSocket services that were originally intended for JS scripts from command-line tools, just like people talk to JSON services that use HTTP cookies for authentication from command-line tools, and that is supported by the protocol, but that's certainly not the primary use case. There'd be no point having features that are _only_ usable by people _not_ using JS scripts in Web pages -- if you want to do something WebSocket can't do, then just use raw TCP. > >> * A mobile phone that is restricted to a single outgoing > >> connection (not uncommon) so the browser wants to > >> transport HTTP over the websocket connection > > > > Could you elaborate on this use case? > > I unfortunately don't have all the details, but I have been a little > involved in the development of a comet system for a large mobile phone > company for global deployment. > > One of the issues that we had to deal with was a single connection limit > that apparently affects many millions of phones. This was a restriction > for a non browser application running on the phone with direct access to > the TCP/IP layer. > > However I'm unclear if the limit was imposed by firmware in the phone or > carriers. Well if there's a limit of a single TCP connection, WebSocket is a lost cause anyway (since you'd block all XHR, HTTP, etc, while the page was open). WebSocket is intended for systems capable of running a full Web browser that can run XHR-based apps today. > >> * Something that none of us has thought of yet > > > > Once we think of it, we can address it. There's no point trying to > > optimise for something we don't know about; we have no way to know if > > we are optimising in the right way. > > I fundamentally disagree - and I think that this difference is probably > at the root of most/all our other differences on the protocol. Possibly. > I think the wait and see position you advocate is entirely correct for > the websocket API. > > But i think it is entirely wrong for the websocket protocol. > > A flexible and extensible protocol can be restricted to known uses by > the API. You then do not need to update the entire network > infrastructure for each and every new idea. Your attempt to "stack out" > the binary protocol is justified by avoiding exactly this type of > breakage. I agree that if there are things we know we will need to support, that we should make sure we can support them. I agree that we should give ourselves forward- and backward-compatible extension points (e.g. the handshake is extensible and we have 253 frame types still available). However, there's no point trying to design the protocol to support every possible extension mechanism, because I *guarantee* that you'll miss the one that you really need, however hard you try, and in the meantime you'll have a protocol with lots of extra complexity that never helps anyone. Consider XML and XML Namespaces. It provides a variety of extension points -- you can add new elements in a new namespace, an element can have new attributes added, etc etc etc. However, XML doesn't support inline binary. It doesn't support an element having two element types. It doesn't support elements overlapping each other. It doesn't support attributes having multiple values. All of these are things that have been needed by various groups at one time or another, despite XML being branded as the ultimate extensible markup metalanguage. So now we have XML and XML namespaces, together making a really expensive mechanism, and yet it doesn't do what people want, despite being designed to be extensible. I think that's not a good state to be in. (PS. Stake out, not stack out. :-) ) > > To send a stream of images with WebSocket, you will need to wait until > > JavaScript gives you a way to get the image data in a usable form. I > > certainly wouldn't recommend sending it as text, that would be stupid. > > I think this is another fundamental disagreement. > > I think the IETF should be considering a bidirectional solution for all > web clients - not just for HTML5 JS clients What's wrong with TCP, BEEP, or Jabber? > If you are designing a non-extensible protocol that only supports HTML5 > websocket API, then you may well end up with something like the > websocket protocol. WebSocket is extensible, just not in the ways you want it to be extensible. But other than that, yes, that's what I'm designing. > But if you want something that is extensible and supports > bidirectionality for any web client, then I think then it will look > substantially different. Wouldn't it look pretty much exactly like TCP, BEEP, or Jabber? -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
- [hybi] HyBi Design Space Salvatore Loreto
- Re: [hybi] HyBi Design Space Infinity Linden (Meadhbh Hamrick)
- Re: [hybi] HyBi Design Space Thomson, Martin
- Re: [hybi] HyBi Design Space Salvatore Loreto
- Re: [hybi] HyBi Design Space Salvatore Loreto
- [hybi] Multiplexing in WebSocket (Was: HyBi Desig… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Infinity Linden (Meadhbh Hamrick)
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Graham Klyne
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] HyBi Design Space Stefano Salsano
- Re: [hybi] HyBi Design Space Thomson, Martin
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Graham Klyne
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Jamie Lokier
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Michael(tm) Smith
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Bjoern Hoehrmann
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… SM
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Martin Tyler
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Ian Hickson
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Julian Reschke
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket (Was: HyBi D… Wellington Fernando de Macedo
- [hybi] new drat design-space-bidirectional Salvatore Loreto
- Re: [hybi] Multiplexing in WebSocket Ian Hickson
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Ian Hickson
- Re: [hybi] Multiplexing in WebSocket Julian Reschke
- Re: [hybi] Multiplexing in WebSocket Ian Hickson
- Re: [hybi] Multiplexing in WebSocket Peter Saint-Andre
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Ian Hickson
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Jamie Lokier
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Ian Hickson
- Re: [hybi] Multiplexing in WebSocket Greg Wilkins
- Re: [hybi] Multiplexing in WebSocket Ian Hickson