Re: [hybi] Max frame size

Brodie Thiesfield <> Thu, 23 June 2011 11:26 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id B31BE11E8137 for <>; Thu, 23 Jun 2011 04:26:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2.677
X-Spam-Status: No, score=-2.677 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_LOW=-1]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id VSIMlbAbeQDU for <>; Thu, 23 Jun 2011 04:26:19 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 23C3F11E807F for <>; Thu, 23 Jun 2011 04:26:19 -0700 (PDT)
Received: by pvh18 with SMTP id 18so1161703pvh.31 for <>; Thu, 23 Jun 2011 04:26:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; 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=sECdP+mcSw5J/Tb+8b5ikVdtD0RN6KC4Q7wmJ57HjiA=; b=f2ZzCdTSaQ5vTcc6cPpeDV3SwFumWXX2KQVtREFCsog57KThzcMQsNfGizIqDO7zG0 FHEmHCRnQyeMp6W+o2B+HBqD+jZV5poeiZmztF/ZrC/87x2yJ4lGdS1f2/8QONJ6BAh2 B2hya30Fbk/ENt8QXEBNNNsKagLmIx6Sf9FFs=
DomainKey-Signature: a=rsa-sha1; c=nofws;; 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=jSylmujwVpQzQ0W1HiEC5vG+5eF9ONPFTavY55+k1b928DTdpu014Yk5XSgwzxizB0 L9CNmN/VoKEA/SAk+vfepFzSfnWCIjzWRY4XLMD6qUv9AiuwcE1SZEPFDMEIHdVq+e7r dkAQwbw2jnehbuegf1PR81D0ffP2XPHLFDu20=
MIME-Version: 1.0
Received: by with SMTP id h7mr982116pbn.152.1308828378654; Thu, 23 Jun 2011 04:26:18 -0700 (PDT)
Received: by with HTTP; Thu, 23 Jun 2011 04:26:18 -0700 (PDT)
In-Reply-To: <1308826861.11268.47.camel@tot.local>
References: <1308720860.5393.18.camel@tot.local> <> <1308738811.11941.704.camel@vulcan.aspl.local> <> <1308756913.11941.823.camel@vulcan.aspl.local> <> <1308826861.11268.47.camel@tot.local>
Date: Thu, 23 Jun 2011 20:26:18 +0900
X-Google-Sender-Auth: yODbhuHvrpgUkzeR8H36iPA8JSs
Message-ID: <>
From: Brodie Thiesfield <>
To: =?ISO-8859-1?Q?Francis_Brosnan_Bl=E1zquez?= <>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Subject: Re: [hybi] Max frame size
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Server-Initiated HTTP <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Thu, 23 Jun 2011 11:26:19 -0000

On Thu, Jun 23, 2011 at 8:01 PM, Francis Brosnan Blázquez
<> wrote:
> Hi Scott,
>> No. It's like a HTTP chunked POST, where the application receives a
>> stream of data, not the underlying HTTP chunks.
>> A server (or client) which exposes the frames as its primary API is
>> doing it wrong.
> I think you are getting my wrong maybe because I mentioned "...which is
> called every single frame is received", but obviously my point is
> ..and you really think this API is suitable for a message oriented
> protocol? (I assuming your fread concept will return bytes as it comes
> not complete messages)

Scott understood you and was only talking about the data, however the
file stream API metaphor might be distracting.

Websocket is a message based protocol, but the message contents are
byte streams that might be split into any number of frames. So your
websocket layer notifies your upper layer only of the messages and
bytes. The frames are a websocket layer concept that the next layer
has no need to know of.

The websocket layer will tell the upper layer about the start of a
message, then feed it bytes until the message is complete, then tell
it that the message is complete. The bytes may come from a single
frame, or multiple frames. The upper layer has no need to know.

Think of the processing as something like the following (note that
control frames, compression, etc is ignored):

while have connection:
    receive frame header
    if first frame in message:
        notify application layer of the start of a message
    receive bytes up to max of frame length:
        pass bytes up to the application layer as message data
    if last frame in message:
        notify application layer that the message is complete

The frames are never notified to the application layer. It doesn't need to know.