Re: [hybi] web socket protocol in "last call"?

Jamie Lokier <jamie@shareable.org> Sun, 01 November 2009 21:34 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 C26B33A68B4 for <hybi@core3.amsl.com>; Sun, 1 Nov 2009 13:34:46 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.076
X-Spam-Level:
X-Spam-Status: No, score=-2.076 tagged_above=-999 required=5 tests=[AWL=-0.077, BAYES_00=-2.599, J_CHICKENPOX_64=0.6]
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 acdx4VdHkDVN for <hybi@core3.amsl.com>; Sun, 1 Nov 2009 13:34:46 -0800 (PST)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id EDFC83A67D6 for <hybi@ietf.org>; Sun, 1 Nov 2009 13:34:45 -0800 (PST)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1N4i4f-0006yf-7v; Sun, 01 Nov 2009 21:34:57 +0000
Date: Sun, 01 Nov 2009 21:34:57 +0000
From: Jamie Lokier <jamie@shareable.org>
To: Ian Hickson <ian@hixie.ch>
Message-ID: <20091101213457.GA25925@shareable.org>
References: <4AE7FFC4.8050405@gmx.de> <4AE806AA.60901@ericsson.com> <Pine.LNX.4.62.0910280938560.25608@hixie.dreamhostps.com> <4AE86513.4060600@ericsson.com> <3a880e2c0910281301j5d1e4cdclfe2391b28eadda0e@mail.gmail.com> <4AE8CA69.2040105@webtide.com> <44abafb90910281604o2a73b490l6b1ae5ca1fba37ba@mail.gmail.com> <Pine.LNX.4.62.0910310127390.25616@hixie.dreamhostps.com> <3f5bf96b0910312029l3a0f755ax39349988fefb53b@mail.gmail.com> <Pine.LNX.4.62.0911012036100.27039@hixie.dreamhostps.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.62.0911012036100.27039@hixie.dreamhostps.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] web socket protocol in "last call"?
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: Sun, 01 Nov 2009 21:34:46 -0000

Ian Hickson wrote:
> On Sat, 31 Oct 2009, Mike Dierken wrote:
> >
> > I had one small question about "[..] the latency involved in having to 
> > establish new TCP connections for each HTTP message is non-existent in 
> > WebSocket". I know that you know that persistent HTTP 1.1 connections 
> > reduce the number of times an open/close of a connection would occur, so 
> > I was curious what's actually happening that connections are created for 
> > each request. (Not that I think the answer will or should change 
> > anything to do with WebSockets, just a curiousity sort of thing).
> 
> Non-idempotent messages have to be sent using POST, which cannot be 
> pipelined in practice.

There are several problems with HTTP pipelining, which make it
unusable for POST and other non-idempotent request.

They are design faults in HTTP pipelining, due to the way TCP behaves
when a socket is closed; they are not intrinsic problems.

Even re-using a _persistent_ connection for POST is fraught because
the server might close the connection, and the client cannot detect
whether it should re-send the request.

There is something else quite non-obvious.  Sending a POST request
_followed_ by pipelining a second (idempotent) request can cause the
POST's response to be lost or truncated.

That's because the server may close the socket after the POST
response.  After that, the second request being in flight can cause
the server TCP to send RST packets which can cause the client to drop
what it has already received.

(Apache has a workaround for this; look up "lingering close", but it's
not described in the HTTP RFCs).

Ironically in these cases, TCP makes a connection less reliable :-)

As far as I can tell, WebSocket seems to have the same problem, which
is unfortunate as pipelining small requests over WebSocket seems like
a very natural thing to do.

Applications can work around it in various ways (e.g. using unique
request ids to detect+drop duplicates, and/or using orderly close
markers), but this is probably unfamiliar territory for most web
application writers.  Most authors will be familiar with AJAX/HTTP,
avoids these issues for POST requests by just not using pipelining.

-- Jamie