Skip to content
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

Fix early close of socket in http_server #1496

Open
wants to merge 1 commit into
base: release-0.6
Choose a base branch
from

Conversation

UncleGrumpy
Copy link
Collaborator

The socket can close too fast for some clients, as exhibited on FreeBSD in recent failing CI tests: https://github.com/atomvm/AtomVM/actions/runs/12977426531/job/36190827478#step:3:5747 Fixed by adding a 5000 ms delay before closing the socket.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

The socket can close too fast for some clients, as exhibited on FreeBSD in recent failing CI tests:
https://github.com/atomvm/AtomVM/actions/runs/12977426531/job/36190827478#step:3:5747
Fixed by adding a 5000 ms delay before closing the socket.

Signed-off-by: Winford <[email protected]>
Copy link
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a fix, but not sure it is the right one.

@@ -77,7 +77,10 @@ reply(StatusCode, ReplyBody, Conn) ->
StatusCode, ReplyBody, [<<"Content-Type: text/html\r\nConnection: close\r\n">>], Conn
),
Socket = proplists:get_value(socket, NewConn),
gen_tcp:close(Socket),
spawn_link(fun() ->
timer:sleep(5000),
Copy link
Collaborator

@bettio bettio Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds quite odd, we are hanging for 5 seconds before closing the socket.
Do we have any open issue about the root cause we are trying to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants