Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Binding http server to file descriptor fails to read #14183

Closed
terinjokes opened this issue Mar 27, 2015 · 5 comments
Closed

Binding http server to file descriptor fails to read #14183

terinjokes opened this issue Mar 27, 2015 · 5 comments
Assignees
Milestone

Comments

@terinjokes
Copy link

I'm attempting to use node.js as a systemd service using "socket activation", where systemd binds to the TCP port and passes a file descriptor to the running service, starting with file descriptor 3.

According to 0.10 and 0.12 documentation, passing this file descriptor to http.Server.listen should work (https://nodejs.org/api/http.html#http_server_listen_handle_callback). The 'listening' event successfully fires, but no connections ever make it to 'request'.

I've setup a test repository to help reproduce this issue: https://github.com/terinjokes/nodejs-systemd-issue

This test repository does work in io.js, so i suspect there's a fix that could be backported, but I was unable to find one in particular.

@misterdjules misterdjules added this to the 0.12.3 milestone Mar 30, 2015
@misterdjules misterdjules self-assigned this Mar 30, 2015
@misterdjules
Copy link

Thank you very much for the detailed description and for the reproduction code!

@misterdjules misterdjules modified the milestones: 0.12.2, 0.12.3 Mar 30, 2015
@misterdjules
Copy link

Fixed in libuv by libuv/libuv#134, which is included in the upgrade to libuv 1.4.2 in Node.js' v0.12 branch. This will be available in the node v0.12.2 release that is planned to be released tomorrow (Tuesday).

As a result, closing and moving to the 0.12.2 milestone.

Let me know if you have any question, thanks!

EDIT: To be more precise, the commit that landed in libuv and that fixes the problem is libuv/libuv@5d4abdb.

@misterdjules
Copy link

Also just for future reference, this is the same issue as #8988.

@terinjokes
Copy link
Author

@misterdjules I can reproduce in 0.10, any recourse recommendations to get this working? Suppose i could ship a native component that calls uv__nonblock(fd, 1) myself, but would be awesome if there was something simpler.

EDIT: I created a module to do this, and my code now works in 0.10. Will edit again when I get it published after I eat some food. :)

EDIT 2: https://www.npmjs.com/package/fds

@piranna
Copy link

piranna commented Nov 23, 2015

@terinjokes, where's the actual GitHub of your module? Also, does it works with fd0?

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

No branches or pull requests

3 participants