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

Connection lost immediately on Mac #1154

Closed
AndrewMHenry opened this issue Jul 11, 2023 · 5 comments
Closed

Connection lost immediately on Mac #1154

AndrewMHenry opened this issue Jul 11, 2023 · 5 comments
Labels
question Further information is requested

Comments

@AndrewMHenry
Copy link

AndrewMHenry commented Jul 11, 2023

Description

1. What are you trying to do?

On my Mac with the latest version of NiceGUI, I'm having trouble running the following "Hello, World"-type program:

from nicegui import ui

ui.label("Hello")

ui.run()

I am running it in a test virtual environment with just nicegui installed into it:

  • NiceGUI version: 1.2.24
  • Python version: CPython 3.10.6
  • OS: macOS Monterey, Version 12.6
  • Processor: 2.3 GHz 8-Core Intel Core i9

2. What do you expect to happen?

The webpage should come up without any error messages.

3. What happens instead?

The webpage comes up, but immediately shows the box with Connection lost.

Other notes

The program works when I replace ui.run() with ui.run(native=True), and I can also run a NiceGUI program on a remote Ubuntu Linux VM and access the webpage successfully from my local machine using port forwarding.

Is anyone else having the same problem? I still have the problem with old versions of NiceGUI, so it doesn't seem like it's due to a recent NiceGUI change.

@rodja
Copy link
Member

rodja commented Jul 12, 2023

Hello @AndrewMHenry. That should not happen. We develop on Mac without problems. Please make sure you have the right version:

from nicegui import ui, __version__

ui.label(f"{__version__=}")

ui.run()

And maybe try reinstalling the package. You could also try another port with ui.run(port=5500) or similar and check your firewall. If the error persists you may want to post the output from Python and the browser debug console error log.

@falkoschindler falkoschindler added the question Further information is requested label Jul 12, 2023
@AndrewMHenry
Copy link
Author

AndrewMHenry commented Jul 13, 2023

Hi @rodja , thanks for the advice! I confirmed that __version__='1.2.24', but changing the port number to 5500 fixed the problem completely and (8081 also worked).

So far, I've only had the problem on ports 8080 and 80. As a test, I tried running

python -m http.server 8080

and I could access the server from my browser without problems (same with port 80). So, it seems like Python can serve on those ports, and my browser can access them.

It's also interesting that serving up a NiceGUI app on 8080 does connect temporarily, rather than failing to connect in the first place. That makes me think it's not a permission issue, but does anyone have thoughts on what else it could be?

Update: It turns out that there were other IT-type processes running on those ports; is it plausible that those processes are causing NiceGUI to disconnect without preventing it from connecting in the first place?

@rodja
Copy link
Member

rodja commented Jul 16, 2023

It turns out that there were other IT-type processes running on those ports; is it plausible that those processes are causing NiceGUI to disconnect without preventing it from connecting in the first place?

No, not to my knowledge. If the port is already used, the NiceGUI server startup should fail and report the blocked port. What was the other "IT-type process"? How to reproduce?

@AndrewMHenry
Copy link
Author

Ok, thanks for following up. The software wasn't familiar to me, and I'm not sure whether it's just company-internal stuff, but I'm currently trying to track it down; if I find anything useful to share about it, I will let you know.

That said, without knowing what the specific software is, when I ran lsof -i :8080 while trying to run NiceGUI on port 8080, the Python/NiceGUI processes were in the LISTEN state, but the other processes were in the ESTABLISHED or CLOSED states.

Is it possible that the other ports are not interfering with the server startup because they are not in the LISTEN state, but that they are somehow still "hogging" the port in a way that slows the connection down for NiceGUI?

@AndrewMHenry
Copy link
Author

Update: Closing this issue. It looks like this problem was based on a new IT policy that affected programs using ports 80 and 8080. They have a new solution that's fixing the problem for me so far, which confirms this is not an issue with NiceGUI but with our particular setup. Thanks for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants