Skip to content

Does not work with Server-Sent Events #17

Closed

Description

@pallymore

So I'm working on a small application which uses Server-Sent Events...everything works perfectly in my local environment, but the server refuses to push out any messages when the app runs on heroku.

I spent quite a few hours trying to debug this.. Then I found out it's because I'm using compression middleware in production environment. everything works again as soon as I remove it.

I'm using the basic SSE implementation, not using any third party library for that. You should be able to reproduce this issue by adding this middleware to any expressjs + SSE code examples. (like this one: https://github.com/TravelingTechGuy/express-eventsource)

I'm fairly new to expressjs. I'd be great if this can be solved (or if anyone can provide a workaround solution).

Thanks!

Activity

  1. dougwilson commented on Jun 18, 2014

    @dougwilson
    Contributor

    You need to call res.flush() after you write your event if you want it actually flushed out to the client. For your demo there, you want to add res.flush() after line 60: https://github.com/TravelingTechGuy/express-eventsource/blob/master/models/eventsource.js#L60 and it works fine.

  2. pallymore commented on Jun 18, 2014

    @pallymore
    Author

    ah...thanks! :)

  3. dougwilson commented on Jun 18, 2014

    @dougwilson
    Contributor
  4. pallymore commented on Jun 18, 2014

    @pallymore
    Author

    thanks again! works perfectly now :)

  5. dougwilson commented on Jun 18, 2014

    @dougwilson
    Contributor

    Awesome! I need to add this information to the README, haha. I'm going to keep this open until I do :)

  6. self-assigned this
    on Sep 8, 2015
  7. locked and limited conversation to collaborators on Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions