Add IPv6 support to StatusServer and related classes. #119

Open
moodyjon wants to merge 8 commits from moodyjon/ipv6 into master
moodyjon commented 2022-12-29 00:07:13 +01:00 (Migrated from github.com)

Fixes #117
Update: Fixes #121

Not sure whether this is complete. I think I need help with this part in hub/env.py:

        if result == 'localhost':
            # 'localhost' resolves to ::1 (ipv6) on many systems, which fails on default setup of
            # docker, using 127.0.0.1 instead forces ipv4
            result = '127.0.0.1'

If I allow the cs_host() to be localhost instead of 127.0.0.1, then it will start TCP servers on both v4/v6 sockets.

What is the problem with docker and this behavior?

Fixes #117 Update: Fixes #121 Not sure whether this is complete. I think I need help with this part in `hub/env.py`: ``` if result == 'localhost': # 'localhost' resolves to ::1 (ipv6) on many systems, which fails on default setup of # docker, using 127.0.0.1 instead forces ipv4 result = '127.0.0.1' ``` If I allow the `cs_host()` to be `localhost` instead of 127.0.0.1, then it will start TCP servers on both v4/v6 sockets. What is the problem with docker and this behavior?
jackrobison (Migrated from github.com) reviewed 2022-12-29 00:07:13 +01:00
moodyjon commented 2023-01-13 16:37:06 +01:00 (Migrated from github.com)

Just saw a new EADDRINUSE problem when running lbry-sdk tests against this hub branch.

https://github.com/moodyjon/lbry-sdk/actions/runs/3911989925/jobs/6686050669

Converting this to draft status while investigating.

Just saw a new `EADDRINUSE` problem when running lbry-sdk tests against this hub branch. https://github.com/moodyjon/lbry-sdk/actions/runs/3911989925/jobs/6686050669 Converting this to draft status while investigating.
moodyjon commented 2023-01-17 16:52:25 +01:00 (Migrated from github.com)

I did some work on StatusServer.start() to make it retry to overcome transient EADDRINUSE. It got a bit more complicated in order to handle cases like HOST=::,0.0.0.0, HOST=0.0.0.0,::, HOST=myserver1,myserver2, etc. I imported resolve_host() from my moodyjon/lbry-sdk:ipv6 branch to do name resolution.

I did some work on `StatusServer.start()` to make it retry to overcome transient `EADDRINUSE`. It got a bit more complicated in order to handle cases like `HOST=::,0.0.0.0`, `HOST=0.0.0.0,::`, `HOST=myserver1,myserver2`, etc. I imported `resolve_host()` from my `moodyjon/lbry-sdk:ipv6` branch to do name resolution.
moodyjon commented 2023-01-17 16:53:32 +01:00 (Migrated from github.com)

Have not seen EADDRINUSE since that one occurrence. Not sure what the root cause of that was. Possible infrastructure?

Have not seen `EADDRINUSE` since that one occurrence. Not sure what the root cause of that was. Possible infrastructure?
moodyjon (Migrated from github.com) reviewed 2023-01-17 16:58:50 +01:00
moodyjon (Migrated from github.com) commented 2023-01-17 16:58:50 +01:00

If I don't disable IPv4 mapping, then the IPv6 port will sometimes seize (or try to seize) responsibility for IPv4. The bad effect is seen when starting the server with HOST=::,0.0.0.0 or HOST=0.0.0.0,::. I forget which one fails, but 1 of these two orderings has persistent EADDRINUSE errors.

If I don't disable IPv4 mapping, then the IPv6 port will sometimes seize (or try to seize) responsibility for IPv4. The bad effect is seen when starting the server with `HOST=::,0.0.0.0` or `HOST=0.0.0.0,::`. I forget which one fails, but 1 of these two orderings has persistent `EADDRINUSE` errors.
moodyjon (Migrated from github.com) reviewed 2023-01-17 17:17:22 +01:00
moodyjon (Migrated from github.com) commented 2023-01-17 17:17:22 +01:00

The bad ordering (on my machine) is HOST=::,0.0.0.0:

2023-01-17 10:14:49,962 - hub.herald.udp - WARNING - started udp6 status server on ('::', 50002)
2023-01-17 10:14:49,963 - hub.herald.udp - ERROR - UDP status server failed to listen on (0.0.0.0:50002) : [Errno 48] Address already in use
2023-01-17 10:14:52,965 - hub.herald.udp - WARNING - started udp6 status server on ('::', 50002)
2023-01-17 10:14:52,966 - hub.herald.udp - ERROR - UDP status server failed to listen on (0.0.0.0:50002) : [Errno 48] Address already in use

HOST=0.0.0.0,:: works fine.

The bad ordering (on my machine) is `HOST=::,0.0.0.0`: ``` 2023-01-17 10:14:49,962 - hub.herald.udp - WARNING - started udp6 status server on ('::', 50002) 2023-01-17 10:14:49,963 - hub.herald.udp - ERROR - UDP status server failed to listen on (0.0.0.0:50002) : [Errno 48] Address already in use 2023-01-17 10:14:52,965 - hub.herald.udp - WARNING - started udp6 status server on ('::', 50002) 2023-01-17 10:14:52,966 - hub.herald.udp - ERROR - UDP status server failed to listen on (0.0.0.0:50002) : [Errno 48] Address already in use ``` `HOST=0.0.0.0,::` works fine.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin moodyjon/ipv6:moodyjon/ipv6
git checkout moodyjon/ipv6

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout master
git merge --no-ff moodyjon/ipv6
git checkout moodyjon/ipv6
git rebase master
git checkout master
git merge --ff-only moodyjon/ipv6
git checkout moodyjon/ipv6
git rebase master
git checkout master
git merge --no-ff moodyjon/ipv6
git checkout master
git merge --squash moodyjon/ipv6
git checkout master
git merge --ff-only moodyjon/ipv6
git checkout master
git merge moodyjon/ipv6
git push origin master
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/hub#119
No description provided.