Re: [hybi] Clarify the role of closing handshake

Brodie Thiesfield <brodie@jellycan.com> Wed, 16 February 2011 00:06 UTC

Return-Path: <brofield@gmail.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 3BA273A6D71 for <hybi@core3.amsl.com>; Tue, 15 Feb 2011 16:06:25 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.977
X-Spam-Level:
X-Spam-Status: No, score=-2.977 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, RCVD_IN_DNSWL_LOW=-1]
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 JOngNJ3NP49g for <hybi@core3.amsl.com>; Tue, 15 Feb 2011 16:06:24 -0800 (PST)
Received: from mail-qw0-f44.google.com (mail-qw0-f44.google.com [209.85.216.44]) by core3.amsl.com (Postfix) with ESMTP id 0159A3A6A53 for <hybi@ietf.org>; Tue, 15 Feb 2011 16:06:23 -0800 (PST)
Received: by qwi2 with SMTP id 2so656327qwi.31 for <hybi@ietf.org>; Tue, 15 Feb 2011 16:06:50 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+IFvcrusdJX5Srr5Kl+C+ozC9L3QRvBreyrVJ7ujvRQ=; b=PCkxhEVkQirsLBX/Xfp8LeAbQHpPRNgENKDv2dOUCe/LuXfbyYTVGB+xR7whB39bM8 Ffgynqr8ckMfFJLKGHqo4WvB9klpkZ2X6LoSguDbehAmi+m9P73EJpMAFowJcVI4h7yW lQZMWSzTxo9bj+8qW/9SH/Ma50h0AvdJtx0IU=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=QoJBoTNayXwuGDEZHwdyrJJ6GEGKhXjTd5Ehdc9V5pIuMFHT9USmbT+lE9v/PTDqri eW9LKrMBFbYIVZioUwC87n78VkXX4YPkZ5rv2RvkW5vrnEr9Nl5EFDkF7qB4mJTyp99k XB/o4EFBsGhmSYcLEnZnQw/UsV5t9IGtJkhrQ=
MIME-Version: 1.0
Received: by 10.224.61.3 with SMTP id r3mr31078qah.134.1297814810185; Tue, 15 Feb 2011 16:06:50 -0800 (PST)
Sender: brofield@gmail.com
Received: by 10.224.187.2 with HTTP; Tue, 15 Feb 2011 16:06:50 -0800 (PST)
In-Reply-To: <AANLkTinXR_kTQ2vFt8AqLWPJd1XYxMxuhbVwGgRGqKO0@mail.gmail.com>
References: <4D5AE318.9080308@stpeter.im> <OF9E69202E.36384265-ON88257838.00749E83-88257838.007782CA@playstation.sony.com> <AANLkTinXR_kTQ2vFt8AqLWPJd1XYxMxuhbVwGgRGqKO0@mail.gmail.com>
Date: Wed, 16 Feb 2011 09:06:50 +0900
X-Google-Sender-Auth: yCyiK9bBNmod-XT-ocItuo0wA0Y
Message-ID: <AANLkTim1+gnSqG==GQt4nJ1RZ-AX=+AU3RvsPHqZ6AiL@mail.gmail.com>
From: Brodie Thiesfield <brodie@jellycan.com>
To: ifette@google.com
Content-Type: text/plain; charset="ISO-2022-JP"
Content-Transfer-Encoding: 7bit
Cc: hybi@ietf.org, Yutaka_Takeda@playstation.sony.com
Subject: Re: [hybi] Clarify the role of closing handshake
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, 16 Feb 2011 00:06:25 -0000

2011/2/16 Ian Fette (イアンフェッティ) <ifette@google.com>:
> I am trying to get out a -06 that resolves some of the CLOSE issues, but
> currently I'm getting caught up by a few other things at work today.
> What I'm currently looking at is this: (comments welcome)
>          <t>The Close message contains an opcode of 0x01.</t>
>           <t>The Close message contains no body (the body has zero
> length).</t>
>           <t>The application MUST NOT send any more data messages after
> sending
>           a close message.</t>
>           <t>If an endpoint receives a Close message and that endpoint did
> not
>           previously send a Close message, the endpoint MUST send a Close
>           message in response. It SHOULD do so as soon as is practical.
>           </t>
>           <t>After both sending and receiving a close message, an endpoint
>           considers the websocket connection closed, and
>           SHOULD close the underlying TCP connection.</t>
>           <t>If a client and server both send a Close message at the same
> time,
>           both endpoints will have sent and received a Close message and
> should
>           consider the websocket connection closed and close the underlying
>           TCP connection.</t>

I would like to see support in the close message for a status
code/reason to show the reason for an abnormal close. The goal is
purely to provide useful information for interop troubleshooting.

At the moment the spec has a number of cases where the connection is
just dropped with no information provided to the peer as to why.
Although from the normal operation of the server this may be optimal,
it is going to make integration testing hell. There needs to be some
way to find out why the remote server is dropping the connection.

I propose that the close message contain a status code and an optional
message. Further, I propose that the peer that following a successful
handshake, the peer that is about to abort the connection SHOULD send
a close message with a valid status code and optionally a more
detailed human readable message. This is valid for both client and
server aborts (i.e. the client is aborting because of an invalid
opcode/incorrectly formatted server message).

An example of the text that I am suggesting, modifying the relevant
bits of what you supplied.

----
The Close message contains an opcode of 0x01.The Close message
contains a body made up of a status code and an optional
human-readable message following the format:

  status = [123] [0-9] [0-9]
  msg    = SP CHAR+
  close  = status msg

The status code ranges are 1xx normal, 2xx message sender error, 3xx
message receiver error.

The application MUST NOT send any more data messages after sending a
close message.
----

If a reply Close message is required as per Ian's text, then I would
modify it as:
----
If an endpoint receives a Close message and that endpoint did not
previously send a Close message, the endpoint MUST send a Close
message with a 100 status (normal close) in response. It SHOULD do so
as soon as is practical.
----

The text on aborts would be changed to note that an abort is actually
a Close with abnormal status + close of transport. If a close message
requires a close reply then the aborting peer would need to wait
around to receive that message (or at least drain the socket to avoid
TCP problems).

Suggested status codes (trying to not get too detailed):

  1xx  Normal close range
    100  Normal close

  2xx  Message sender error range
    200  Message sender general error
    201  Invalid opcode
    202  Invalid framing (e.g. RSV bits used but not negotiated,
fragmented control msg)
    203  Invalid encoding (e.g. invalid UTF-8)

  3xx  Message receiver error range
    300  Message receiver internal error
    301  Overloaded / service unavailable
    302  Message too long (i.e. longer than this server/intermediatary supports)

Regards,
Brodie