v
v copied to clipboard
vweb: host 0.0.0.0 breaks with -prod and flags
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.
Also fails when you put 127.0.0.1, maybe with another values also fails
It didn't reproduce, but I tested it on MacOS. Are you sure your port 8080 is free?
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
That's a bit weird. I tested it on rockylinux and it passed...
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: https://github.com/vlang/v/pull/20448 action: https://github.com/vlang/v/actions/runs/7459400961/job/20295324077?pr=20448
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 */
@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.
Maybe the problem occurs when it's only available ipv4, when try to bind to ipv6 and it's not available it's failing
It seems that now it's working as spected.
It's failing again, I can't reproduce in local
With the alpine image of vlang when building it, if you use this:
RUN echo "net.ipv6.conf.all.disable_ipv6 = 1" > /etc/sysctl.d/01-disable-ipv6.conf
CMD ["sysctl", "-p", "/etc/sysctl.d/01-disable-ipv6.conf"]
It disables ipv6 and it work as spected
@esquerbatua so it fails still if IPv6 is enabled?
@esquerbatua so it fails still if IPv6 is enabled?
Now I'm not sure, but disabling ipv6 inside the container never failed again