Giter Club home page Giter Club logo

Comments (8)

josephg avatar josephg commented on July 30, 2024

I have two different proposals for this:

  1. In between updates in a subscription, the client will ignore any arbitrary number of newline (\n) characters. These newlines may be inserted periodically by the server to keep a connection alive.
  2. Allow "empty" update messages. Eg Heart: beat\n\n between real updates

My preference is (1), though I'm happy to be convinced if anyone has another idea. Otherwise I'll write up a PR.

from braid-spec.

canadaduane avatar canadaduane commented on July 30, 2024

Both options seem reasonable. I also prefer (1).

from braid-spec.

josephg avatar josephg commented on July 30, 2024

Me too. I've made this change to braid-protocol to send \n newlines as heartbeat messages, and the client ignores any newlines between updates.

from braid-spec.

mitar avatar mitar commented on July 30, 2024

Shouldn't heartbeats be done at a transport level and not at braid level? E.g., if subscriptions are done using SSE, then you can use some hearbeat event type. If you use Websockets, then you can use built-in heartbeats.

from braid-spec.

toomim avatar toomim commented on July 30, 2024

Shouldn't heartbeats be done at a transport level and not at braid level?

To clarify, Braid defines protocols over different transports (e.g. HTTP and WebSocket), and yes, the encoding of a heartbeat will be different on each one. In this issue we've been discussing how to encode heartbeats in the Braid-HTTP version.

If you use Websockets, then you can use built-in heartbeats.

Good call! I hadn't realized it until you brought it up, but WebSockets do have a built-in ping/pong frame type: https://stackoverflow.com/a/46112000

This isn't exposed in the Javascript APIs for web browsers, but clients will respond to a ping with a pong if the server initiates the ping.

from braid-spec.

mitar avatar mitar commented on July 30, 2024

WebSockets built-in ping might be a problem if we care that the JavaScript client knows if the connection is still up or not.

from braid-spec.

josephg avatar josephg commented on July 30, 2024

The connection should get closed automatically by the browser when the server goes down or there’s a timeout. I guess we could speed up that timeout if we send our own ping messages. We could add a no-op update message I suppose. I’m not sure how much this matters in practice.

from braid-spec.

toomim avatar toomim commented on July 30, 2024

This has been implemented in 9651ad0. Closing.

from braid-spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.