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

Support IPV6 in _find_http_port() #1207

Merged
merged 2 commits into from
Feb 7, 2023
Merged

Conversation

schnell18
Copy link
Contributor

When I try to deploy the jupyterlab server in an environment with IPV6 address, the server fail to start with stack trace like:

Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-lab", line 10, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.10/site-packages/jupyter_server/extension/application.py", line 607, in launch_instance
    serverapp = cls.initialize_server(argv=args)
  File "/opt/conda/lib/python3.10/site-packages/jupyter_server/extension/application.py", line 577, in initialize_server
    serverapp.initialize(
  File "/opt/conda/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2550, in initialize
    self.init_httpserver()
  File "/opt/conda/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2371, in init_httpserver
    self._find_http_port()
  File "/opt/conda/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2419, in _find_http_port
    tmp_sock.bind((self.ip, port))
socket.gaierror: [Errno -9] Address family for hostname not supported

This pull request is to solve the problem by detect if the address to listen to is an IPV6 address, if so it construct a socket object with family set to AF_INET6. Otherwise, it fails back to the original code path.

Please consider accepting this patch to make user on IPV6 happier.
Thanks for your attention!

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 80.33% // Head: 80.44% // Increases project coverage by +0.11% 🎉

Coverage data is based on head (27984a8) compared to base (0111798).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1207      +/-   ##
==========================================
+ Coverage   80.33%   80.44%   +0.11%     
==========================================
  Files          68       68              
  Lines        8116     8117       +1     
  Branches     1581     1581              
==========================================
+ Hits         6520     6530      +10     
+ Misses       1180     1174       -6     
+ Partials      416      413       -3     
Impacted Files Coverage Δ
jupyter_server/serverapp.py 80.05% <100.00%> (+0.10%) ⬆️
jupyter_server/gateway/managers.py 83.60% <0.00%> (+0.23%) ⬆️
...ter_server/services/kernels/connection/channels.py 61.06% <0.00%> (+1.32%) ⬆️
jupyter_server/extension/handler.py 69.23% <0.00%> (+1.53%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@schnell18 schnell18 changed the title Support IPV6 when find a usable http port Support IPV6 in _find_http_port() Feb 7, 2023
Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@blink1073 blink1073 merged commit ee6c660 into jupyter-server:main Feb 7, 2023
@welcome
Copy link

welcome bot commented Feb 7, 2023

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@blink1073
Copy link
Contributor

Thanks! The failure is unrelated.

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

Successfully merging this pull request may close these issues.

2 participants