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

vweb: host 0.0.0.0 breaks with -prod and flags #20441

Open
esquerbatua opened this issue Jan 8, 2024 · 10 comments
Open

vweb: host 0.0.0.0 breaks with -prod and flags #20441

esquerbatua opened this issue Jan 8, 2024 · 10 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@esquerbatua
Copy link
Contributor

esquerbatua commented Jan 8, 2024

Describe the bug

Gives this error:
V panic: failed to listen 0 net: socket error: 9; code: 9; binding to 0.0.0.0:8080 failed
v hash: 6b3449b

Reproduction Steps

Run vweb with 0.0.0.0 as host and a port, with this flags: v -prod -d no_segfault_handler . or v -prod -cflags "-static" .

module main

import vweb

struct App {
	vweb.Context
}

fn main() {
	vweb.run_at(&App{}, vweb.RunParams{
		host: '0.0.0.0'
		port: 8080
		family: .ip
	}) or { panic(err) }
}

Expected Behavior

Run as dev builds:
'[Vweb] Running app on http://0.0.0.0:8080/'

Current Behavior

V panic: failed to listen 0 net: socket error: 9; code: 9; binding to 0.0.0.0:8080 failed
v hash: 6b3449b

Possible Solution

No response

Additional Information/Context

No response

V version

latest (0.4.3 6b3449b)

Environment details (OS name and version, etc.)

OS: linux, Ubuntu 22.04.3 LTS
Processor: 64bit, little endian
CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@esquerbatua esquerbatua added the Bug This tag is applied to issues which reports bugs. label Jan 8, 2024
@esquerbatua
Copy link
Contributor Author

Also fails when you put 127.0.0.1, maybe with another values also fails

@esquerbatua esquerbatua changed the title vweb: host 0.0.0.0 breaks with -prod vweb: host 0.0.0.0 breaks with -prod and flags Jan 8, 2024
@shove70
Copy link
Contributor

shove70 commented Jan 9, 2024

It didn't reproduce, but I tested it on MacOS.
Are you sure your port 8080 is free?

@esquerbatua
Copy link
Contributor Author

esquerbatua commented Jan 9, 2024

Yes, it's free, I tested also inside a docker with the image alpine:latest, and also fails

FROM thevlang/vlang:alpine-dev AS builder

WORKDIR /app
RUN v up
COPY . .
RUN v -prod -cflags "-static" -o test .

FROM alpine:latest

WORKDIR /app

COPY --from=builder /app/test ./

EXPOSE 8080

ENTRYPOINT [ "./test" ]

I have not tested the example, but with a vweb version with more code it's failing with the same error

@shove70
Copy link
Contributor

shove70 commented Jan 9, 2024

That's a bit weird. I tested it on rockylinux and it passed...

@esquerbatua
Copy link
Contributor Author

esquerbatua commented Jan 9, 2024

Yep, now in ubuntu fails, but in alpine it's working (with more flags), but in that PR it's failing, not with the same error code but:
#20448
action: https://github.com/vlang/v/actions/runs/7459400961/job/20295324077?pr=20448

@hholst80
Copy link
Contributor

If you consistently can get a failed PR there should be a precise repro. The code you posted here seems to work fine for us, under the conditions you provided.

PS. you quoted two different socket error codes - is it 99 or 9? In the PR it's 99.

#define	EADDRNOTAVAIL	99	/* Cannot assign requested address */
#define EBADF            9      /* Bad file number */

@esquerbatua
Copy link
Contributor Author

@hholst80 I'm getting the two errors, in different systems, I'm going to try to get an example to repoduce it.
They are both errors, 9 and 99.

@esquerbatua
Copy link
Contributor Author

Maybe the problem occurs when it's only available ipv4, when try to bind to ipv6 and it's not available it's failing

@esquerbatua
Copy link
Contributor Author

It seems that now it's working as spected.

@esquerbatua
Copy link
Contributor Author

It's failing again, I can't reproduce in local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

3 participants