valum-framework / valum

Web micro-framework written in Vala
https://valum-framework.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
225 stars 23 forks source link

[question] Could not listen on address ::1, port 80 (g-io-error-quark, 0) #221

Closed devnix closed 5 years ago

devnix commented 5 years ago

Hi! I'm taking the docs quickstart, but I'm stuck on one of the most basic steps.

When I build the app I only get this message (apart from tons of compilation warnings from Valum):

** (app:6): CRITICAL **: [2019-03-16T14:49:41.000Z] vsgi-application.vala:172: Could not listen on address ::1, port 80 (g-io-error-quark, 0)                                                                                                                         

It doesn't make any difference if I change the port. I also tried to install and run Apache and it works perfectly, so I just don't get what I'm doing wrong!

I'm building and runnig the project in Docker. You can check it out here: https://github.com/devnix/valabb

devnix commented 5 years ago

PS: labelling as question on the title because I am not able to assign labels.

devnix commented 5 years ago

Ok, seems like I fixed it with the --ipv4-only param, but I'm just getting an ERR_EMPTY_RESPONSE. If I stop the server I will get an expected ERR_CONNECTION_REFUSED, so it seems to be working in some way...

No matter what I try I will not get any output, even with the examples given on this repo.

arteymix commented 5 years ago

Have you tried to expose one example from your container?

The simplest HTTP app is in examples/vsgi/app.vala.

devnix commented 5 years ago

That example gives to me an ERR_SOCKET_NOT_CONNECTED or an ERR_CONNECTION_RESET randomly. Is it expecting a WSGI connection instead of an HTTP one?

arteymix commented 5 years ago

Try to add --any, otherwise it will listen only on the loopback.

arteymix commented 5 years ago

I meant --address 0.0.0.0:62481, I'm not sure if --any works at all.

devnix commented 5 years ago

It's working! If I deliberatedly call a random path I get a "The request URI '/test' was not found." in the browser, but if I visit the / route, instead of getting my Hello world! text on the screen the browser generates me a file download with that content. I don't know if that's what I should expect of the current code inside my repo

arteymix commented 5 years ago

That's definately what you should expect from your code. You have a single route defined on / that output Hello world!.

I'm trying to push a v0.3.16 release that works on the latest LTS image (Ubuntu Bionic). Stay tuned!

devnix commented 5 years ago

But a file download?

arteymix commented 5 years ago

You have to add:

res.headers.set_content_type ("text/plain", null);

Otherwise, the browser will assume it is binary (i.e. application/octet-stream).

arteymix commented 5 years ago

The clean way of doing this is by adding content negotiation. If the browser does not accept this type of content, an error will be raised and basic will handle it by producing the appropriate status code.

using Valum.ContentNegotiation;
app.use (accept ("text/plain"));
arteymix commented 5 years ago

Stable docs are here by the way: https://valum-framework.readthedocs.io/en/stable/

devnix commented 5 years ago

Okay, now I'm working on a structure for my project. I think I can close the issue, thank you so much!