mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #207] Using websocket causes socket leaks in nginx #138
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @andreymal on GitHub (Nov 10, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/207
I use nginx with configuration similar to this:
and after these steps:
I've noticed that restarting nginx is taking longer than usual. I checked
/var/log/nginx/error.logand found this:I tested several other projects that also use websockets, but could not reproduce it. Only Mailpit causes this error.
I think this is because, unlike other projects, Mailpit doesn't try to read anything from the websocket and therefore doesn't know it's already closed.
If my assumption is correct, this error could be solved by adding a loop that reads the websocket and does nothing else, something like (disclaimer — I'm not a Go expert):
@axllent commented on GitHub (Nov 10, 2023):
I believe you're absolutely correct @andreymal, the websockets do appear to be left open it seems (disregarding the nginx entirely). I think they time out eventually, but a proactive approach is needed. I think I've found a solution but I need to do a bit more testing first.
@axllent commented on GitHub (Nov 11, 2023):
@andreymal A fix for this has just been released in v1.10.0. Please confirm this solves your issue? Thanks.
@andreymal commented on GitHub (Nov 11, 2023):
@axllent yes 👍
(but using
ReadMessageinstead ofNextReaderallocates memory, and an evil client could kill Mailpit by sending a giant message likewebsocket.send(new ArrayBuffer(1024 * 1024 * 1024)), but if you don't care about evil clients then okay)@axllent commented on GitHub (Nov 11, 2023):
Awesome, thanks for the quick feedback, and the note re:
NextReader()- you're right about that (hadn't crossed my mind). I have made that change which will be included in the next release.@axllent commented on GitHub (Nov 19, 2023):
Just a FYI - the switch to
NextReader()was included in the v1.10.1 release 👍