Re: [hybi] thewebsocketprotocol #28 (new): Fragmentation

Jamie Lokier <jamie@shareable.org> Wed, 24 November 2010 20:36 UTC

Return-Path: <jamie@shareable.org>
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 5A25028C13A for <hybi@core3.amsl.com>; Wed, 24 Nov 2010 12:36:59 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[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 0rwB9KUz0NgJ for <hybi@core3.amsl.com>; Wed, 24 Nov 2010 12:36:58 -0800 (PST)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id C4F0E28C117 for <hybi@ietf.org>; Wed, 24 Nov 2010 12:36:57 -0800 (PST)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1PLM6H-0002YR-8c; Wed, 24 Nov 2010 20:37:57 +0000
Date: Wed, 24 Nov 2010 20:37:57 +0000
From: Jamie Lokier <jamie@shareable.org>
To: Zhong Yu <zhong.j.yu@gmail.com>
Message-ID: <20101124203757.GZ22787@shareable.org>
References: <059.5b3c3b280c1320a26d9c11c25e067e06@tools.ietf.org> <AANLkTinE95cwFQjFWc3SYsWFYSiY4mu27oQpedYJGgDJ@mail.gmail.com> <AANLkTikS+N4ZjhoRLgZv5yetD2LceWXO=KC2ksgbfySQ@mail.gmail.com> <AANLkTimaRzGObYrTCB8p7qbvqUpPPhR-uErNRaV_wPzr@mail.gmail.com> <AANLkTikzKLVT=kYKoc67rsZOaeP=0hKe8rkk7y8kuimH@mail.gmail.com> <20101124104050.GY22787@shareable.org> <AANLkTim4djXE2DXdqpn5kSbHPj93UgE3rOvO7vvUE+=m@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <AANLkTim4djXE2DXdqpn5kSbHPj93UgE3rOvO7vvUE+=m@mail.gmail.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: hybi <hybi@ietf.org>
Subject: Re: [hybi] thewebsocketprotocol #28 (new): Fragmentation
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: Wed, 24 Nov 2010 20:36:59 -0000

Zhong Yu wrote:
> On Wed, Nov 24, 2010 at 4:40 AM, Jamie Lokier <jamie@shareable.org> wrote:
> > Zhong Yu wrote:
> >> The most important thing I think is the abstraction WS provides to app
> >> developers. Right now the abstraction is simple -- one message after
> >> another. The simplicity is a good thing, if it is compromised I don't
> >> know what websocket is supposed to be any more.
> >
> > Right now, WS provides *two* abstractions: The one to app developers,
> > and the one over TCP.
> >
> > Some of us believe they *should not be the same* due to network
> > engineering issues *because that makes the app developer's job easier*.
> >
> > Right now, the "simplicity" of WS means *robust* apps need to
> > implement half of TCP in Javascript on the client, which is not a good
> 
> That's where frameworks come in, which can provide degrees of
> robustness suitable for different applications. I don't think WS
> should or could address these application level concerns.

Certain concerns *cannot* be addressed at the Javascript level, or
they are hard to do.  Some of them are technical (connection/keepalive
aggregation, network error indication); some of them are social
because authors are motivated by self-interest, not aggregate
behaviour.  Frameworks don't make independently-written components on
the same page/server share connections/keepalives, and even *using* a
single framework, it's not clear if it's technically able to share
connections to the same server.

Ironically this makes HTTP way more efficient than WebSocket for some
kinds of small messaging when multiple pages are open, yet less
efficient for a single page and few components.  You can guess which
will be optimised for, by most authors.  The effect is not insignificant.

> The #1 feature needed for robustness is auto reconnect. Nobody
> proposed to build that feature in the WS protocol.

For a very good reason: No matter how much the system tries to auto
reconnect, at some point the application *must* be able to handle the
fact that connection is lost and can't be restored.  They must also
decide what to send on reconnection; queuing everything and resending
it all would be disastrous for many apps, after a long delay.

Since applications must handle that anyway (and it's easy to script),
there is little point *for the app* to have WS doing it automatically.

(There is a network reason though: Local congestion collapse, and
router NAT overflow, due to many pages/components repeatedly retrying
connections without backoff...)

If anything, #1 is a way to *detect when* a connection is dead and a
reconnect advisable.

> > sign.  (For example the "tic tac toe" example, which is supposed to be
> > simple, can lock up on real networks: No more moves when a TCP is
> > silently dropped.  A HTTP equivalent doesn't have this problem.)
> >
> > Why do you think the two abstractions should be the same?
> 
> They should not be. But no matter how complex the protocol must
> become, I wish it won't jeopardize the simple application abstraction.
> I don't want WebSocket to become WebService, and everybody needs to
> buy a 1000 page "The Definitive Guide".

I'm pretty sure everyone in the design discussions agrees on keeping
the application abstraction simple.

I'm dismayed that attempts to make the application abstraction *simpler*
by making the network layer work a bit harder are repeatedly
misunderstood as the opposite.

A glaringly obvious example is the way, as you've pointed out, that
the only robust way to use *current* WebSocket is with a "framework".
Many of the protocol proposals make it robust, and scale better, while
using the WebSocket object directly from scripts - without changing
the application abstraction *at all*.

> > That said, I'm not sure why we need to support messages with unknown
> > lengths in advance in the simplest protocol level anyway.  Is there a
> > use case for control frames such as graceful close or error indication
> > in the middle of a message?
> >
> > The use cases which come to my mind are: Keepalives - those are
> > desirable in th middle of a large message, if the message is being
> > generated slowly;
> 
> If it is so slow and it exceeds the timeout, who are we to say that
> the connection is "alive"? The ping-pong test certainly says nothing
> about application liveliness. I don't see the point.

It's not to detect application aliveness!!  That's a different
problem, which needs the app to explicitly participate.

You need regular keepalives to keep TCP connected through a NAT.  The
interval needed for that varies (a lot), but I have seen NATs drop
connections after as little as 30 seconds TCP inactivity, including
delays from TCP's own timers.

The problem of NAT is only going to get worse.

I see nothing wrong with applications caring about their own behaviour
(such as liveness / app reconnect/resync logic), while the silly NAT
behaviour is something they shouldn't have to deal with.

The simplest abstraction is probably a pipe that stays open as long as
the network can sustain it smoothly (i.e. without long interruptions
and unsustainable queueing).  Whether the pipe carries
messages/text/bytes is less important.

That implies NAT keepalives, that can always be sent, even in the
middle of a long message if they can be produced incrementally.

-- Jamie