You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
dougwilson commentedon Jun 18, 2014
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 addres.flush()after line 60: https://github.com/TravelingTechGuy/express-eventsource/blob/master/models/eventsource.js#L60 and it works fine.pallymore commentedon Jun 18, 2014
ah...thanks! :)
pallymore commentedon Jun 18, 2014
Actually...it seems there's no such method :/
(as of ExpressJS 4)
http://nodejs.org/api/http.html#http_response_write_chunk_encoding
dougwilson commentedon Jun 18, 2014
res.flushis added by this library: https://github.com/expressjs/compression/blob/master/index.js#L161I do need to add that to the readme, it seems.
pallymore commentedon Jun 18, 2014
thanks again! works perfectly now :)
dougwilson commentedon Jun 18, 2014
Awesome! I need to add this information to the README, haha. I'm going to keep this open until I do :)