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: devcontainer interface binding #995

Closed
wants to merge 2 commits into from
Closed

Conversation

endrl
Copy link

@endrl endrl commented Nov 19, 2024

Add interface binding to the config.

Tested

closes: #677
Requires: loco-rs/loco-devcontainer#1

@jondot
Copy link
Contributor

jondot commented Nov 20, 2024

@endrl thanks for this PR! also thanks for adjusting and updating the base_template, i'm happy you found it.
this change is hard to accept since NODE_BINDING is not a universal thing -- is there a different way to achieve what you're trying to solve?

@endrl
Copy link
Author

endrl commented Nov 20, 2024

Thank you for you fast response,
i tinkered a little bit and this is what i noticed in docker

# with interface localhost <-- broken port forward
 sudo netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.11:39899        0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:45457         0.0.0.0:*               LISTEN      258/node            
tcp6       0      0 ::1:5150                :::*                    LISTEN      1572/target/debug/s 

# with interface 0.0.0.0 <-- works
sudo netstat -tulpn | grep LISTEN
tcp        0      0 0.0.0.0:5150            0.0.0.0:*               LISTEN      1772/target/debug/s 
tcp        0      0 127.0.0.11:46355        0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:38659         0.0.0.0:*               LISTEN      258/node   

# with interface 127.0.0.1 <-- works
sudo netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:5150          0.0.0.0:*               LISTEN      1788/target/debug/s 
tcp        0      0 127.0.0.11:43631        0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:44405         0.0.0.0:*               LISTEN      258/node 

A strange ipv6 bind is going on with localhost. I don't know why, especially there is no ipv6 network. The node port forward that devcontainer uses is a syscall to 127.0.0.1:PORT. But 127.0.0.1 is not reachable when loco binds to localhost

The vs code docs recommends to bind to 0.0.0.0.

Possible solutions

  • Revert from localhost back to 0.0.0.0 and listen on all interfaces (universal)
  • Change from localhost to 127.0.0.1
  • Add a config option, so users can choose. So you can bind just to a specific ipX network for example.

I think the devcontainer setup should work out of the box, i was trapped because of the following config comment

 # Port on which the server will listen. the server binding is 0.0.0.0:{PORT}

This might be also a docker bug... If you look at the docs of appPort
Edit: Found docker/for-mac#7269

@jondot
Copy link
Contributor

jondot commented Dec 12, 2024

this is solved in upcoming version, we have a new BINDING env var.

@jondot jondot closed this Dec 12, 2024
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.

Updating to version 0.6.2 causes unresponsive server
2 participants