Open michealroberts opened 8 months ago
@michealroberts is your endpoint working if you remove
case <-c.Context().Done():
fmt.Println("Client disconnected. Closing connection.")
return
@efectn Yeh, so it still doesn't work when removing that unfortunately π
I have a branch here: https://github.com/observerly/nox/pull/48 for a full reproduction that you should be able to access. In that code, I've added the basic example given in the gofiber/examples repo for SSE setup, line for line, and unfortunately it still doesn't work ...
Are you able to work with SSE on the latest versions of Fiber and fasthttp?
@efectn Yeh, so it still doesn't work when removing that unfortunately π
I have a branch here: observerly/nox#48 for a full reproduction that you should be able to access. In that code, I've added the basic example given in the gofiber/examples repo for SSE setup, line for line, and unfortunately it still doesn't work ...
Are you able to work with SSE on the latest versions of Fiber and fasthttp?
This one works for me https://paste.laravel.io/8c6a1464-4f52-46c1-b362-ab49f5ad60cf
@efectn Aye aye aye, ok. I feel like I have narrowed it down to be able to replicate it.
I have the ETag middleware installed from github.com/gofiber/fiber/v2/middleware/etag ... I guess this somehow causes issues in terms of headers π€
What are your thoughts on this? I should be able to get a minimal reproduction.
@efectn Aye aye aye, ok. I feel like I have narrowed it down to be able to replicate it.
I have the ETag middleware installed from github.com/gofiber/fiber/v2/middleware/etag ... I guess this somehow causes issues in terms of headers π€
What are your thoughts on this? I should be able to get a minimal reproduction.
Yes it seems. You can disable etag for specific path like:
app.Use(etag.New(etag.Config{
Next: func(c *fiber.Ctx) bool {
return c.Path() == "/sse"
},
}))
@efectn I think I will disable ETags globally for now, I have quite a number of SSE routes.
I wonder if I should open up a separate minimal, reproducible, example of the SSE + ETag issue, and maybe start to work on a possible fix ...
I have the same problem.
I will start working on this issue this week.
Question Description
Versions:
Go 1.21.5 github.com/gofiber/fiber/v2 v2.52.0 github.com/valyala/fasthttp v1.51.0
Issue
I have the following logic inside of an SSE handler:
Which to me, looks good. I can log the message without issue ...
However, when connecting from a browser side client ... the connection is stuck in the "connecting" phase of the event source connection.
I can see, that when the endpoint is called from my client, the server is logging correctly:
But the connection remains as pending:
Also, no errors when requesting
application/json
(so for me, it isn't a case that the underlying code has an issue):The front end JS code is standard for the EventSource API.
Headers
Reproduction
I can also provide access to the repository for a minimal reproduction if the issue isn't apparent from what I have supplied if needed, please just request access for your username and I can provide it (as long as you are listed as a core maintainer of this repo).
Code Snippet (optional)
Checklist: