Using EventSource with SSE

Поделиться
HTML-код
  • Опубликовано: 11 окт 2024
  • In this video, we'll use the native EventSource interface to receive Server-Sent Events from a Node.js Express server and examine common pitfalls like buffering issues with popular NPM packages like compression.
    GitHub Repo: github.com/cov...
    Express Template Repo: github.com/cov...
    Don't forget to like this video and subscribe to our channel - we're publishing more videos and walkthroughs every week. Comment below and let us know what you'd like to see next!
    Join the Covalence community: covalence.io
    Shop Covalence merch: covalence.merc...

Комментарии • 18

  • @bobkelso5681
    @bobkelso5681 9 месяцев назад +2

    Awesome. You caught so many details that other tutorials just ignore, like the nginx headers and the close event handling.

  • @michaelayoub2211
    @michaelayoub2211 Год назад +1

    Not the utils folder! 😂 Just kidding. Appreciate your videos.

  • @KautilyaBhardwaj
    @KautilyaBhardwaj 8 месяцев назад

    Hi, awesome explanation. Kudos to that.
    However, I'm wondering:
    1. How to know if the SSE was delivered to the destination.
    2. Can we rely on SSEs to deliver any critical information? if not, what are the alternatives - queue before SSE?

    • @covalence-io
      @covalence-io  8 месяцев назад +1

      You could use some kind of handshake logic to know something was received (an acknowledgement of some kind). I think the second part is a similar question to the first. Any method of delivery is fine for critical information as long as we know the information was received. Anything critical should definitely be stored somewhere and again there should be some kind of indication or acknowledgement that the information was received by whoever needed to receive it.

  • @yogeshvishnole1264
    @yogeshvishnole1264 Год назад +1

    Superb video sir. Can you please also create a video for authentication in SSE.

    • @covalence-io
      @covalence-io  Год назад

      Check out our video on WebSocket auth here ruclips.net/video/twNgfrE4ShE/видео.html
      It can be done almost the exact same way by passing up an authentication token as a query parameter in the URL.
      Another option would be to use fetch instead of EventSource as seen here ruclips.net/video/GXGFCXn9Hak/видео.html
      You can use your headers when you're using fetch to perform auth like any other request.

  • @sporksto4372
    @sporksto4372 7 месяцев назад

    I can't thank you enough! You saved me so much time! I have a question tho. When I directly make an HTTP request to the API, I noticed that it appends new JSON documents to the existing response. I'm wondering if it's actually possible to overwrite the same HTTP response directly, so we don't have to parse the response on the client side, and we don't have to waste bandwidth with each update, both for sending and receiving, as the response grows.

    • @covalence-io
      @covalence-io  7 месяцев назад

      I'm not sure I'm understanding you question entirely. The client side will receive whatever you write to the response stream. In my video I was writing JSON objects each time, so that's why we parsed the data on each 'message' event on the frontend. If you just wrote strings or numbers it would receive only that string or number on each message.

  • @julesbloux4279
    @julesbloux4279 2 месяца назад

    Genial, toi tu prends ton abonnement

  • @povdata
    @povdata Год назад

    How to scale SSE servers and how to spin up then if it fails?

    • @covalence-io
      @covalence-io  Год назад

      A flexible node environment can be useful for scaling SSE servers... using something like GCP app engine

    • @povdata
      @povdata Год назад

      @@covalence-io could you recommend something to read about scaling sse?

  • @theonewhowas7709
    @theonewhowas7709 Год назад

    whats the point in typing what you're copying?
    you're looking at you're other screen typing and copying from someone else.. why? to act like you know how to code?? idk??
    just show the source and explain it.. instead of acting like you know what to type

    • @covalence-io
      @covalence-io  Год назад +1

      Every one of my videos references code I've previously written for some other project because we make these videos to help others with problems we've already faced. Thank you for the feedback.

    • @theonewhowas7709
      @theonewhowas7709 Год назад

      @@covalence-io makes sense.... sorry

    • @covalence-io
      @covalence-io  Год назад

      @@theonewhowas7709 it's all good! Happy coding.

    • @Khungersumit
      @Khungersumit 9 месяцев назад

      Atleast he is trying/tried, look youserlf before pointing out others. You seem too much of a negative person