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

Regression #249 - failed to listen to address with default #2756

Open
hholst80 opened this issue Nov 25, 2023 · 1 comment
Open

Regression #249 - failed to listen to address with default #2756

hholst80 opened this issue Nov 25, 2023 · 1 comment

Comments

@hholst80
Copy link

hholst80 commented Nov 25, 2023

# dmd --version
DMD64 D Compiler v2.105.3

Up-to-date vibe-d 0.9.7: target for configuration [library] is up to date.
[main(----) INF] Listening for requests on http://[::]:1337/
Failed to listen on 0.0.0.0:1337

Which is strange because there is nothing listening on IPv4 on port 1337.

# ss -tlpn
State    Recv-Q   Send-Q      Local Address:Port        Peer Address:Port   Process                                                                     
LISTEN   0        4096              0.0.0.0:27017            0.0.0.0:*       users:(("mongod",pid=1286,fd=11))                                          
LISTEN   0        4096            127.0.0.1:8384             0.0.0.0:*       users:(("syncthing",pid=1492,fd=26))                                       
LISTEN   0        10           127.0.0.1%lo:53               0.0.0.0:*       users:(("connmand",pid=1029,fd=12))                                        
LISTEN   0        511             127.0.0.1:10002            0.0.0.0:*       users:(("node",pid=1311,fd=20))                                            
LISTEN   0        511             127.0.0.1:10000            0.0.0.0:*       users:(("node",pid=1311,fd=18))                                            
LISTEN   0        511             127.0.0.1:10001            0.0.0.0:*       users:(("node",pid=1311,fd=19))                                            
LISTEN   0        10               [::1]%lo:53                  [::]:*       users:(("connmand",pid=1029,fd=13))                                        
LISTEN   0        4096                    *:22000                  *:*       users:(("syncthing",pid=1492,fd=13))   

If I set bindAddresses to 127.0.0.1 or even 0.0.0.0 it works, as expected.

# cat source/app.d
import std.stdio;
import std.conv;
import std.net.curl;
import std.array;
import std.process;
import vibe.d;

int main() {
    // Configure server settings
    auto settings = new HTTPServerSettings;
    settings.port = 1337;
    // settings.bindAddresses = ["0.0.0.0"];

    // Initialize server
    auto router = new URLRouter;

    // Start the server
    listenHTTP(settings, router);

    return runEventLoop();
}
[main(----) INF] Listening for requests on http://0.0.0.0:1337/
@s-ludwig
Copy link
Member

It looks like this is a discrepancy between the default approach to listen on ::1 and 0.0.0.0 and the system's network configuration, where ::1 probably implicitly also handles IPv4 traffic. Unfortunately there are also systems where you need to listen on both separately, so it's not really possible to implement a fits-all solution. For real-world applications, this will have to be made configurable.

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

No branches or pull requests

2 participants