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

[MacOS]: Websocket infinite reconnection for locally hosted instance #1774

Open
wildalc opened this issue Feb 12, 2024 · 6 comments
Open

[MacOS]: Websocket infinite reconnection for locally hosted instance #1774

wildalc opened this issue Feb 12, 2024 · 6 comments
Labels
⚡ Type: Bug Something isn't working

Comments

@wildalc
Copy link

wildalc commented Feb 12, 2024

Mainsail Version:

v0.8.0-310

Browser:

Chrome

Device:

Laptop

Operating System:

macOS

What happened?

The issue was initially posted here #1632, Arksine/moonraker#726 and Rat-OS/RatOS#106.

Similar issue was reported on Reddit

What did you expect to happen instead?

It should work on MacOS Monterey, Ventura, Sonoma.

How to reproduce this bug?

  1. Follow RatRig's installation instructions https://os.ratrig.com/docs/introduction/
  2. After the setup, open http://ratos.local/ or http://<IP_ADDRESS>.
  3. Open the networks tab, and see the WebSocket infinite reconnection request
  4. Only port 80 does this, but when you visit port 7125 or ratos.local/configure it works perfectly.
    NOTE: the same problem was reproduced with Voron Installing Mainsail instructions
**cat ../logs/moonraker.log**

2024-02-12 19:10:49,889 [application.py:log_request()] - 101 GET /websocket (192.168.10.152) [_TRUSTED_USER_] 4.53ms
2024-02-12 19:10:49,890 [websockets.py:open()] - Websocket Opened: ID: 3898713448, Proxied: True, User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36, Host Name: 192.168.10.151
2024-02-12 19:10:49,896 [websockets.py:on_close()] - Websocket Closed: ID: 3898713448 Close Code: None, Close Reason: None, Pong Time Elapsed: 0.01


**cat mainsail-access.log**

192.168.10.152 - - [12/Feb/2024:20:02:11 +0000] "GET /websocket HTTP/1.1" 101 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0
.0 Safari/537.36"
192.168.10.152 - - [12/Feb/2024:20:02:13 +0000] "GET /websocket HTTP/1.1" 101 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0
.0 Safari/537.36"
192.168.10.152 - - [12/Feb/2024:20:02:15 +0000] "GET /websocket HTTP/1.1" 101 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0
.0 Safari/537.36"

**cat mainsail-error.log**
<empty>

Additional information:

The problem is see with MacOS Monterey, Ventura, Sonoma (running on Intel, 2018).
I tried older laptops with versions MacOS BigSur, Catalina and it works fine (running on Intel, 2012).
On my new M1 with fresh MacOS Sonoma it works.
MacBook-2018 was upgraded from Ventura to Sonoma with no luck. Please note that on this machine I played with Proxy settings before upgrade.

In 2022 I had similar issue, but then I was able to add printer's IP address with port 7125 under Interface Settings -> Printers -> ADD PRINTER. I had to do that every time I started the 3D printer (running RatOS).

@wildalc wildalc added the ⚡ Type: Bug Something isn't working label Feb 12, 2024
@meteyou
Copy link
Member

meteyou commented Feb 13, 2024

Thanks for this bug report, but did you read the last message in the old bug report? #1632 (comment)
please don't open new issues for the same issue...

Furthermore, there has never been a Mainsail version with the version number v0.8.0-310...

But if it works for you, even on different devices with the same operating system, it sounds very much like a problem with your device (wrong network/proxy settings).

Port 80 successfully opens the web interface (you see Mainsail itself), but it cannot connect to your Moonraker instance (the connecting/init dialog). If you open :7125 or ratos/configurator, you only open an HTTP web interface. These don't connect with the WebSocket. Your issue is only the WebSocket connection!

But as I wrote already in the other issue: as long as I cannot reproduce this issue, I'm not able to fix it...

@meteyou meteyou closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
@wildalc
Copy link
Author

wildalc commented Feb 13, 2024

Thanks for your message. I agree that the problem is communication between some OS and Moonraker, and therefore those OS's are the outliers. However Moonraker is the only service I have experienced issues with reverse proxy...

Would it be possible for you to recommend some debugging steps on Moonraker / Nginx?

@meteyou
Copy link
Member

meteyou commented Feb 13, 2024

I did not say that the OS generally causes issues. I have been working exclusively on Mac for a long time and never had this problem. It's a setting of your specific setup on the 2018 Intel device...

a reverse proxy is always a special setup. we do not officially support it, so you are on your own. but reverse proxies need their own settings for a WebSocket connection, as this socket must be kept open. but this is generally a reverse proxy "issue".

@wildalc
Copy link
Author

wildalc commented Feb 13, 2024

Thanks for your reply. On MacBookPro there is yet a bridge and virtual interfaces, which can mix up the source interface/address when reaching a webserver (in our case the reverse proxy). So before mirroring the switch port where my printer resides and wireshark the communication, I decided to delete all virtual interfaces. Rebooted the system and that fixed the problem.

Here is step by step what helped me:

  1. On your Mac, choose Apple menu > System Settings, then click Network in the sidebar.
  2. On the right, scroll to the bottom of the window, click the Action pop-up menu ...v , then choose Manage Virtual Interfaces.
  3. Delete everything you have in there.
  4. Reboot your MacBook and printer.

@meteyou
Copy link
Member

meteyou commented Aug 17, 2024

I think we found the issue (thanks to a user on Discord). It appears that the 'Screen Time' feature in macOS is causing the issue. If I set the Screen Time function on a website like 'reddit.com' (which was the exact case from the discord user), I can reproduce the issue.

Please check if you are using this feature in macOS. I would appreciate feedback to see if this is indeed the problem for everyone here.

You can find the function here:

Settings > Screen Time -> Content & Privacy

Disable the complete feature to double-check it. Don't forget to reboot your mac after disabling it!

Link to the Discord post: https://discord.com/channels/758059413700345988/1274313808852029482

@jpwolfe9912
Copy link

@meteyou Holy crap! This worked! I've been dealing with this for the past couple years and have been beyond confused. Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants