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

Moonraker does not fall back to IPv4 if IPv6 isn't available. #941

Open
ccallahan opened this issue Jan 19, 2025 · 1 comment
Open

Moonraker does not fall back to IPv4 if IPv6 isn't available. #941

ccallahan opened this issue Jan 19, 2025 · 1 comment
Labels
bug Something isn't working pending feedback Waiting for more information

Comments

@ccallahan
Copy link

What happened

I have an AnyCubic Kobra 3 running Klipper, Moonraker, and Fluidd. The build of Linux released by Rockchip (the OEM that makes the SOC which powers it) has IPv6 fully disabled, as in the kernel modules for it don't even exist. The issue I'm running into is that when Moonraker goes to query DNS to find an IP address, in this case SimplyPrint, it errors out because the v6 address being returned by DNS is not supported by the networking stack.

2025-01-20 06:32:02,549 [simplyprint.py:_connect()] - Failed to connect to SimplyPrint
Traceback (most recent call last):
  File "/useremain/home/ytka/moonraker/moonraker/components/simplyprint.py", line 201, in _connect
    self.ws = await tornado.websocket.websocket_connect(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/useremain/dist/lib/python3.11/site-packages/tornado/simple_httpclient.py", line 340, in run
    stream = await self.tcp_client.connect(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/useremain/dist/lib/python3.11/site-packages/tornado/tcpclient.py", line 279, in connect
    af, addr, stream = await connector.start(connect_timeout=timeout)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/useremain/dist/lib/python3.11/site-packages/tornado/tcpclient.py", line 109, in start
    self.try_connect(iter(self.primary_addrs))
  File "/useremain/dist/lib/python3.11/site-packages/tornado/tcpclient.py", line 127, in try_connect
    stream, future = self.connect(af, addr)
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "/useremain/dist/lib/python3.11/site-packages/tornado/tcpclient.py", line 316, in _create_stream
    socket_obj = socket.socket(af)
                 ^^^^^^^^^^^^^^^^^
  File "/useremain/dist/lib/python3.11/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol

I can't be the only one who is running into this. I believe logic should be added to detect the above failure and fall back to a IPv4 address.

Client

Mainsail, Fluidd

Browser

Other or N/A

How to reproduce

Create an environment where IPv6 connectivity is impossible. The issue should present itself at that point.

Additional information

No response

@ccallahan ccallahan added the bug Something isn't working label Jan 19, 2025
@Arksine
Copy link
Owner

Arksine commented Jan 20, 2025

The client library (in this case Tornado) handles DNS resolution prior to establishing the connection. Its default behavior is to query using socket.AF_UNSPEC, that is no family is specified. Python should only query socket families supported by the system. This makes it seem like there may be an issue with the python build. If you ssh in and run the following, what does it return?

python3 -c "import socket; print(socket.has_ipv6)"

@Arksine Arksine added the pending feedback Waiting for more information label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending feedback Waiting for more information
Projects
None yet
Development

No branches or pull requests

2 participants