Re: [hybi] Is it important to know frame length at the start of frame? (was: Re: Discontinuation of mux ...)

Joakim Erdfelt <joakim@intalio.com> Tue, 18 February 2014 18:08 UTC

Return-Path: <joakim@intalio.com>
X-Original-To: hybi@ietfa.amsl.com
Delivered-To: hybi@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A27B01A06E8 for <hybi@ietfa.amsl.com>; Tue, 18 Feb 2014 10:08:42 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.777
X-Spam-Level:
X-Spam-Status: No, score=-0.777 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, J_CHICKENPOX_64=0.6, J_CHICKENPOX_75=0.6, RCVD_IN_DNSWL_LOW=-0.7] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YwpiD9rWWc0i for <hybi@ietfa.amsl.com>; Tue, 18 Feb 2014 10:08:39 -0800 (PST)
Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by ietfa.amsl.com (Postfix) with ESMTP id 7B2C71A0524 for <hybi@ietf.org>; Tue, 18 Feb 2014 10:08:37 -0800 (PST)
Received: by mail-ee0-f44.google.com with SMTP id c13so7938479eek.17 for <hybi@ietf.org>; Tue, 18 Feb 2014 10:08:33 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=WbRqLQVS8G6jgUWsz6nHCelSkN/u46EAMz1BrJnOHtA=; b=eWW78xMl8Idz/3hDP/o+Ifd88Jf/Ia5eDtwD494Ld0Eu6OIkPwl6MhKWtNo0XhO3MW MQcStgRMxIKdgaofaSsTRRuAEpuAqOHtDgCbjxvcIAm60W5p0xGkRdNNNZKFCb9gN5Y5 OsNwyTeOlgQlvLRv8nd/0uoVwo/SkyzPFT/FvspwniqSSZ5rUxB/ZJguHEzHmI3GRadn uWOfab6KD2RgPAJkjao2SXKATckxvBn7+Hoog9HHm87Z+UKAtpdidqU8LFn+zgdaR8yA T2IK6Lk68nfaQ5p2WPZV6ydi+zGY1/+Dt4oNtvtXNLCPyujK6zIHyFHdvLJ9t3th7e61 L4qg==
X-Gm-Message-State: ALoCoQleG9offtXragmwx9KE0gEil1poOMTRD28PXHGJbGdztVZzqQ6SPwprSI+iXV3P+1KvAg/n
MIME-Version: 1.0
X-Received: by 10.14.103.67 with SMTP id e43mr205786eeg.94.1392746913896; Tue, 18 Feb 2014 10:08:33 -0800 (PST)
Received: by 10.14.152.202 with HTTP; Tue, 18 Feb 2014 10:08:33 -0800 (PST)
In-Reply-To: <CAH9hSJbzra7uz7yfKQwfZaP_jhnxwdZyx8JnwCmBGhiMk6rbtg@mail.gmail.com>
References: <CAH9hSJbf_ABT7ECL9eS=_ADrncX8qBtxZv=uLcdu9_6GUv23Uw@mail.gmail.com> <CACuKZqEcA1Pv8RpWfmThMjTzi2BbVMMKXqujs6BxVfxRPZJ9NQ@mail.gmail.com> <CAG4zZZCr4aTfVpw2coX2g0qw++4kdgNCFVze6tHKZ+fJNqb0aQ@mail.gmail.com> <CAG4zZZA4WR50Ea2e36XEgTgpJURwiMFn+DXeYuxHFfZatYzDOQ@mail.gmail.com> <CAH9hSJYv5VXGjS7AfG12-ArEvE6Uj_eE6pPxAiQcchcgV8vHcg@mail.gmail.com> <CAH9hSJbzra7uz7yfKQwfZaP_jhnxwdZyx8JnwCmBGhiMk6rbtg@mail.gmail.com>
Date: Tue, 18 Feb 2014 11:08:33 -0700
Message-ID: <CAG4zZZC1cmaH36znAvVLZE_MyJ+ThNk1Ky7tQ-QnKf_qwiQNDw@mail.gmail.com>
From: Joakim Erdfelt <joakim@intalio.com>
To: Takeshi Yoshino <tyoshino@google.com>
Content-Type: multipart/alternative; boundary="001a11c289ac10e8b704f2b229ba"
Archived-At: http://mailarchive.ietf.org/arch/msg/hybi/ZZAQyHGTETsAGPTIYHolq3vKJEc
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] Is it important to know frame length at the start of frame? (was: Re: Discontinuation of mux ...)
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/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, 18 Feb 2014 18:08:42 -0000

I'm not sure I was clear, as you seem to still have questions and are
hinting at alternatives.

The most important thing I said:
   The size is important at the start of any payload about to be received.

All other statements are based off of that.
The nuanced questions you are asking seems to indicate that you treat a
frame differently than a message is irrelevant.
If the frame happens to represent a complete message (eg:
opcode=(text|binary) + fin=true) vs being only 1 frame belonging to a
series of frames that make up a whole message makes no difference to the
statement.

Since websocket is message based, not stream based, the above core
statement remains true.

The fail-fast example applies for fragmented or whole messages.

some pseudo code:

   header = frame.parse_header(network_bytes)
   if (header.size > system_memory_constraints) then
      fail_protocol(1009)
      return
   end
   // is message still being collected and not yet delivered to local
endpoint?
   if (message.delivered == false) then
      if (message.size + header.size > message.max_constraints) then
        fail_protocol(1009)
        return
      else
        payload = frame.read_payload(network_bytes)
        message.append(payload)
      end
   end
   if (header.fin == true) then
      message.deliver_to(local_endpoint)
      message.reset
   end


--
Joakim Erdfelt <joakim@intalio.com>
webtide.com <http://www.webtide.com/> - intalio.com/jetty
Expert advice, services and support from from the Jetty & CometD experts
eclipse.org/jetty - cometd.org


On Mon, Feb 17, 2014 at 10:37 PM, Takeshi Yoshino <tyoshino@google.com>wrote:

> So, to be clear, Joakim, you're not objecting to make it unable to know
> the size of each frame, but objecting to make it completely unable to know
> the size of big messages on receiving the head of it, right?
>
> Your use case (fail-fast) seems to require the sender to send messages
> unfragmented. So, it sounds like application (or kind of application)
> specific needs. You could do some application specific hack such as
> introducing "complete-message-size" header in the payload than depending on
> protocol level length header. If not, clients in the wild which are out of
> your control may do arbitrary fragmentation. FYI, Chromium's WebSocket
> stack is being refactored and after that it starts sending big messages as
> fragmented into small frames.
>