Re: [hybi] Are keep-alives necessary? Was: Re: NAT reset recovery? Was: Extensibility mechanisms?

Jamie Lokier <jamie@shareable.org> Tue, 20 April 2010 21:29 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 52BB028C0DC for <hybi@core3.amsl.com>; Tue, 20 Apr 2010 14:29:21 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.598
X-Spam-Level:
X-Spam-Status: No, score=-1.598 tagged_above=-999 required=5 tests=[AWL=-1.599, BAYES_50=0.001]
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 U3DTLD-Oh5bB for <hybi@core3.amsl.com>; Tue, 20 Apr 2010 14:29:17 -0700 (PDT)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id 7BFD03A6BE6 for <hybi@ietf.org>; Tue, 20 Apr 2010 14:28:06 -0700 (PDT)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1O4Kz5-00053X-Hw; Tue, 20 Apr 2010 22:27:55 +0100
Date: Tue, 20 Apr 2010 22:27:55 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Hugh Winkler <hugh.winkler@wellstorm.com>
Message-ID: <20100420212755.GL11723@shareable.org>
References: <s2t927441b31004200917x1d05b3f1jbbe5bb9e270f1c38@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <s2t927441b31004200917x1d05b3f1jbbe5bb9e270f1c38@mail.gmail.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] Are keep-alives necessary? Was: Re: NAT reset recovery? Was: Extensibility mechanisms?
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, 20 Apr 2010 21:29:21 -0000

Hugh Winkler wrote:
> On Mon, Apr 19, 2010 at 4:36 PM, Vladimir Katardjiev <vladimir@d2dx.com> wrote:
> > Having said that, from a mobile perspective this is disastrous. In
> > the worst-case scenario, if your keepalive interval is 5 minutes,
> > you could end up sending a keepalive message every 2.5
> > minutes. This would wake up the radio twice as often, and,
> > consequently, halve battery life. In a scenario where the server's
> > keepalive is triggered by the client's, the message from the
> > server would likely arrive within the timeframe that the radio is
> > "awake" anyway (3-5 seconds on smartphones) and thus avoid waking
> > it up again.
> 
> I'm unsure keep-alives are driven by requirements.
> 
> It's only necessary to keep the connection alive across long periods
> of no activity if you require that applications can expect their
> connections to be stateful.
> 
> One requirement of web sockets protocol is that it must support WSAPI.
> So if WSAPI were to explicitly say that applications may not expect
> the remote end of a connection to maintain state across send()s, then
> a client implementation of WSP could just initiate a new TCP
> connection, if it discovers upon sending that the underlying
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> connection has been closed.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^

It takes TCP a very long time to discover that the connection has gone
away after sending - depending on how it went away.

We're talking between 15 minutes and 2 hours, depending on platform.
(Max TCP retransmits, if platform doesn't use TCP-level keepalives.)

Nobody wants a web page showing their live inbox that is 2 hours out
of date because it didn't know to make a new connection.

> WSAPI as written doesn't explicitly say whether applications can
> expect the server to maintain state, and I think reasonable people can
> assume that's implied by the semantics of "connection". But if the
> WSAPI explicitly were to say that send() is idempotent, then WSP
> wouldn't need to keep the TCP connection alive. An implementation
> could open a new TCP connection under the hood for any send. And
> handset manufacturers would thank you.

Letting send() messages be duplicated by the WS implementation (which
is what idempotent means here) is not reasonable.  Application writers
would routinely ignore that part of the spec because it doesn't happen
most of the time and it's hard to work with.  It *could* be hidden
from applications with unique message ids and a history buffer on the
server, however.

Disconnecting when idle breaks things like "online presence" and
"client receives event when something happens on server".

Those are big reasons for using WebSocket.

Handset manufacturers would not be happy, because your proposal would
force those kind of apps to send a request every few seconds, like
they do today over HTTP and we're trying to improve on.  (Think of
Facebook etc. using up your phone's battery despite no updates.)
(Multiply by 20 other background apps.)

-- Jamie