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

Browser gets an "ERR_CONNECTION_REFUSED" when trying to run a web build locally with serve.py script #90695

Closed
midiphony opened this issue Apr 15, 2024 · 4 comments · Fixed by #90698

Comments

@midiphony
Copy link

midiphony commented Apr 15, 2024

Tested versions

System information

(irrelevant but) Godot v4.2.1.stable - Windows 10.0.19045

Issue description

When running the script (like this : python .\serve.py --root .), the local HTTP server starts, then my browser automatically starts and opens the URL "http://127.0.0.1:8060". But my browser gets an ERR_CONNECTION_REFUSED.

However, the files are accessible with those URLs : "http://localhost:8060/" or "http://[::1]:8060/"
It is consistent with the command logs : "Serving HTTP on :: port 8060 (http://[::]:8060/) ..."

A potential solution

Other people are editing the URL in the script to make it work in browser : #76631

I am not experienced enough with Python and the http.server module, but maybe the module is only using the IPv6 loopback address ? As a solution, should we put localhost instead of 127.0.0.1 in the script ?

For context

The serve.py Python script file is a script intended to test the web editor, but it can also be used to test exported projects. It's a convenient script, as it is setting the CORS Headers needed to run a Godot 4 project on a client. The Godot documentation itself encourages to use it : https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_web.html#serving-the-files:~:text=The%20Godot%20repository%20includes%20a%20Python%20script%20to%20host%20a%20local%20web%20server.
er.er.

Steps to reproduce

Expected behaviour :

  • The browser properly gets the directory listing at the root folder "." from the local HTTP server.

Actual behaviour :

  • The browser displays an "This site can't be reached" with an ERR_CONNECTION_REFUSED

Workaround :

Minimal reproduction project (MRP)

Just test the Python script at https://github.com/godotengine/godot/blob/master/platform/web/serve.py

@akien-mga
Copy link
Member

akien-mga commented Apr 15, 2024

CC @Faless @Calinou @adamscott

@Faless
Copy link
Collaborator

Faless commented Apr 15, 2024

So, it appears this is some Windows-specific regression introduced in python 3.8 , which was fixed in later version ( python/cpython#17851 ) but will still probably affect us for the way we use the http.server module.

I think we probably do the same and use the DualStackServer class instead of the base HTTPServer class. Edit: Nevermind, that's an internal class, but we can extend HTTPServer and call setsockopt ourselves.

@Faless
Copy link
Collaborator

Faless commented Apr 15, 2024

@midiphony I've opened #90698 can you confirm it solves the issue for you?

Note that the first load may still result in an error, just refresh the page once in case, and it should work if the fix is correct (see #84439 / #90352 for more info on the first-load error).

@akien-mga akien-mga added this to the 4.3 milestone Apr 15, 2024
@midiphony
Copy link
Author

I'm late but it solves the issue, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants