-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server-Sent Events support #4826
Comments
Looks like a nice abstraction! |
See discussion in nestjs#4826
See discussion in nestjs#4826
@soyuka do you plan to use the standard nodejs http? Because in case we have a fastify app or express we could have this SEE but I'm not sure if you need to receive an Adapter like Nestjs does |
Please see #4842, it's indeed based on nodejs http and it will be compatible with express or fastify adapters without changes. Indeed, we're working directly on the response stream which fastify and express are based on. |
See discussion in nestjs#4826
Hi, is there any update on this? |
PR is ready on my end, waiting on reviews from the nest team. Feel free to try this out: #4826 and give some feedbacks. |
See discussion in nestjs#4826
@kamilmysliwiec any idea how soon are we releasing this? Our product currently needs this as soon as possible |
See discussion in nestjs#4826
same here; anyone have any updates ? |
See discussion in nestjs#4826
See discussion in nestjs#4826
See discussion in nestjs#4826
See discussion in nestjs#4826
Added in 7.5.0 |
@kamilmysliwiec @soyuka where can we see the documentation for this? |
@Sharique-Hasan Check the documentation repository but it might not be added yet |
Hi documentation is in nestjs/docs.nestjs.com#1387 A small example script is available at #4842 Last but not least I created a sample application in https://github.com/nestjs/nest/tree/master/sample/28-sse |
If we use pm2 to spawn multiple instance of app, will there be multiple open connection as well ? Another question is can pass in params to identify unique user in url ? |
Probably but I'd suggest to use cookies for authentification or use the mercure protocol if things get complicated, there's an implementation in node https://github.com/Ilshidur/node-mercure also.
The instance called will open a connection. |
How UseGuards can be combinated with Sse ?
i got unexpected 401 error on client side:
|
i fixed it on client request by adding headers like this:
so
works like a charm!! |
@kuriel-trivu can you post some sources about passing headers in the |
|
@thematan I am also running into a problem with SSE and fastify CORS however am not having luck inject response obj and setting manually. Can you show me how to do that? |
|
sweet, thanks @thematan I'll give that a go |
Feature Request
Describe the solution you'd like
Considering that Nest supports Websocket out of the box, would you like to see Server-Sent Events available as well?
There are lots of cases where using a simple EventSource client-side is sufficient over adding a whole new protocol to the stack (Websocket).
Teachability, Documentation, Adoption, Migration Strategy
On a first thought, and as it's available on top of HTTP, one could have an api like this:
On the client side:
Sse directive would take an optional prefix and handle the sse stream (could use https://github.com/EventSource/node-ssestream although the maintenance isn't my favorite I tend to use a custom transformer), it'd handle the
id
if needed.I'd be glad to contribute such a feature if you guys are up for it!
The text was updated successfully, but these errors were encountered: