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

Dual stack network is not detected with several servers #4996

Open
kimden opened this issue Jan 14, 2024 · 1 comment
Open

Dual stack network is not detected with several servers #4996

kimden opened this issue Jan 14, 2024 · 1 comment

Comments

@kimden
Copy link
Contributor

kimden commented Jan 14, 2024

Description

I'm running a few servers on the same machine that has both IPv4 and IPv6, and since around the end of 2022 with high probability not both of them are detected. That is, when starting the server, there's around 35% probability that IPv6 won't be available, around 35% probability that IPv4 won't be available, and otherwise dual stack network is detected.
In all those cases, the machine can successfully ping anything else in the network using any of protocols, and STK is the only service unable to detect something. The probabilities don't depend on almost anything (like server config, server type, port), except that two servers restarted at the same moment are a bit more likely to detect the same type of network. Sometimes I'm lucky to restart servers with 1.5x number of restarts, but for one specific server there might be needed up to 10-20(-rarely 40-...) restarts to make it detect both IPvX, and so most of the time I stop when there's at least IPv4 detected.

While I'm not typically using the standard version of the STK servers (though I never modified networking code, especially in the part of connection), I tested the standard version a few times throughout this time and it fails in the same way. At some point, I tried to bisect to find a commit where it breaks (both for the version I use and for the standard STK) but it failed for both on all commits made in a few last years. I suspect the problem is in the settings. Upgrading the system (Ubuntu server) did not help on either of occasions. There are no other major apps running on the machine.

I have no idea about how detection is done, to be honest. At some point I thought it's done using stun servers, and then I found out that linuxreviews stun server doesn't respond. Removing it and adding google stun servers slightly improved the situation, but now sometimes I get a strange warning STKHost: Failed to get enough stun servers using SRV record. that otherwise doesn't affect anything. Logs are listed below.

Strangely enough, starting a single 2.x server (which has another config folder) alongside all the 'buggy' servers is OK and it detects dual stack network almost always (haven't tried doing it 1000 times, though). Starting a single server per machine is also OK in the same fashion. Bots have no problems connecting to servers no matter which type of network the server detected (which is kind of logical).

I acknowledge that while server hosting is not very popular, the issue only touches directly a few people at max, but it's still quite annoying because it either causes people with non-dual stack network to not be able to join, or forces to spend more time restarting the servers (and makes it impossible to restart automatically, which means that a properly updated server requires presence in person — and sometimes it's hard to guarantee that).

Steps to reproduce

Start several servers with different ports on the same machine.

Configuration

STK release version: latest git but probably almost any commit works

STK Source (PPA, distribution package, official binary, etc.): git pull

System: Ubuntu Server 20.04, 22.04

Graphics card, CPU: ???

Additional information

Typical success log (IPv4 detected, IPv6 detected):

[warn   ] material: Track uses deprecated texture 'fuzzy.png'
[warn   ] material: Track uses deprecated texture 'chrome.png'
[warn   ] material: Track uses deprecated texture 'skyscraper1.png'
[warn   ] Material: Cannot determine texture full path: shadow_xenia.png
[warn   ] KartProperties: Can't find kart type '' for kart 'Xfce mouse', defaulting to 'light'.
[warn   ] KartModel: xp5.spm has no striaght frame defined.
[warn   ] KartModel: xr-buggy.spm has no striaght frame defined.
[info   ] HTTPRequest: Sending userid=USERID&token=************************&visitingid=USERID to https://online.supertuxkart.net/api/v2/user/get-friends-list/
[info   ] NetworkConfig: System is dual stack network.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named ip_ban will used.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named ipv6_ban will used.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named online_id_ban will used.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named player_reports will used.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named ip_mapping will used.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Table named ipv6_mapping will used.
Fri Jan 12 12:11:19 2024 [info   ] STKHost: Host initialized.
Fri Jan 12 12:11:19 2024 [info   ] STKHost: Server port is PORT
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: 61040 was last server session max host id.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Resetting the server to its initial state.
Fri Jan 12 12:11:19 2024 [info   ] ProtocolManager: A 11ServerLobby protocol has been started.
Fri Jan 12 12:11:19 2024 [warn   ] STKHost: Failed to get enough stun servers using SRV record.
Fri Jan 12 12:11:19 2024 [info   ] main: Creating a WAN server 'SERVER NAME'.
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Public IPv4 server address IPV4.IPV4.IPV4.IPV4:PORT
Fri Jan 12 12:11:19 2024 [info   ] ServerLobby: Public IPv6 server address IPV6:IPV6:IPV6:IPV6:IPV6:IPV6:IPV6:IPV6
Fri Jan 12 12:11:19 2024 [info   ] HTTPRequest: Sending userid=USERID&token=************************&SOMEPARAMETERS to https://online.supertuxkart.net/api/v2/server/create/
Fri Jan 12 12:11:19 2024 [info   ] STKHost: Listening has been started.
Fri Jan 12 12:11:19 2024 [warn   ] STKHost: No direct socket available, this server may not be connected by lan network
Fri Jan 12 12:11:20 2024 [info   ] ServerLobby: Server 90725 is now online.

Typical 'fail but no one cares about IPv6' log (IPv4 detected, IPv6 not detected):

[warn   ] material: Track uses deprecated texture 'fuzzy.png'
[warn   ] material: Track uses deprecated texture 'chrome.png'
[warn   ] material: Track uses deprecated texture 'skyscraper1.png'
[warn   ] Material: Cannot determine texture full path: shadow_xenia.png
[warn   ] KartProperties: Can't find kart type '' for kart 'Xfce mouse', defaulting to 'light'.
[warn   ] KartModel: xp5.spm has no striaght frame defined.
[warn   ] KartModel: xr-buggy.spm has no striaght frame defined.
[info   ] HTTPRequest: Sending userid=USERID&token=************************&visitingid=USERID to https://online.supertuxkart.net/api/v2/user/get-friends-list/
[info   ] NetworkConfig: System is IPv4 only.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named ip_ban will used.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named ipv6_ban will used.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named online_id_ban will used.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named player_reports will used.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named ip_mapping will used.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Table named ipv6_mapping will used.
Sun Jan 14 09:10:15 2024 [info   ] STKHost: Host initialized.
Sun Jan 14 09:10:15 2024 [warn   ] STKHost: Disable IPv6 socket due to missing IPv6.
Sun Jan 14 09:10:15 2024 [info   ] STKHost: Server port is PORT
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: 128667 was last server session max host id.
Sun Jan 14 09:10:15 2024 [info   ] ServerLobby: Resetting the server to its initial state.
Sun Jan 14 09:10:15 2024 [info   ] ProtocolManager: A 11ServerLobby protocol has been started.
Sun Jan 14 09:10:15 2024 [info   ] main: Creating a WAN server 'SERVER NAME'.
Sun Jan 14 09:10:16 2024 [info   ] STKHost: Listening has been started.
Sun Jan 14 09:10:16 2024 [warn   ] STKHost: No direct socket available, this server may not be connected by lan network
Sun Jan 14 09:10:16 2024 [info   ] ServerLobby: Public IPv4 server address IPV4.IPV4.IPV4.IPV4:PORT
Sun Jan 14 09:10:16 2024 [info   ] HTTPRequest: Sending userid=USERID&token=************************&SOMEPARAMETERS to https://online.supertuxkart.net/api/v2/server/create/
Sun Jan 14 09:10:16 2024 [info   ] ServerLobby: Server 91001 is now online.

Typical fail log (IPv4 not detected, IPv6 detected):

[warn   ] material: Track uses deprecated texture 'fuzzy.png'
[warn   ] material: Track uses deprecated texture 'chrome.png'
[warn   ] material: Track uses deprecated texture 'skyscraper1.png'
[warn   ] Material: Cannot determine texture full path: shadow_xenia.png
[warn   ] KartProperties: Can't find kart type '' for kart 'Xfce mouse', defaulting to 'light'.
[warn   ] KartModel: xp5.spm has no striaght frame defined.
[warn   ] KartModel: xr-buggy.spm has no striaght frame defined.
[info   ] HTTPRequest: Sending userid=USERID&token=************************&visitingid=USERID to https://online.supertuxkart.net/api/v2/user/get-friends-list/
[error  ] SocketAddress: Error in getaddrinfo for SocketAddress (str constructor) ipv4only.arpa: No address associated with hostname
[info   ] NetworkConfig: System is IPv6 only.
[warn   ] NetworkConfig: NAT64 prefix not found, you may not be able to join any IPv4 only servers.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named ip_ban will used.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named ipv6_ban will used.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named online_id_ban will used.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named player_reports will used.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named ip_mapping will used.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Table named ipv6_mapping will used.
Sun Jan 14 09:14:07 2024 [error  ] ServerLobby: Error preparing database for vector query SELECT distinct tokens from tokens;: no such column: tokens
Sun Jan 14 09:14:07 2024 [warn   ] ServerLobby: Could not make a query to retrieve tokens.
Sun Jan 14 09:14:07 2024 [info   ] STKHost: Host initialized.
Sun Jan 14 09:14:07 2024 [info   ] STKHost: Server port is PORT
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: 6404 was last server session max host id.
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Resetting the server to its initial state.
Sun Jan 14 09:14:07 2024 [info   ] ProtocolManager: A 11ServerLobby protocol has been started.
Sun Jan 14 09:14:07 2024 [warn   ] STKHost: Failed to get enough stun servers using SRV record.
Sun Jan 14 09:14:07 2024 [info   ] main: Creating a WAN server 'SERVER NAME'.
Sun Jan 14 09:14:07 2024 [info   ] STKHost: Listening has been started.
Sun Jan 14 09:14:07 2024 [warn   ] STKHost: No direct socket available, this server may not be connected by lan network
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Public IPv6 server address IPV6:IPV6:IPV6:IPV6:IPV6:IPV6:IPV6:IPV6
Sun Jan 14 09:14:07 2024 [info   ] HTTPRequest: Sending userid=USERID&token=************************&SOMEPARAMETERS to https://online.supertuxkart.net/api/v2/server/create/
Sun Jan 14 09:14:07 2024 [info   ] ServerLobby: Server 91004 is now online.

Note that I never experienced situations when both protocols were not detected.

Used stun servers (different from default only by removing linuxreviews and adding google I think):

<!-- The stun servers that will be used to know the public address (ipv4 only) with port -->
<ipv4-stun-servers>
    <stun-server address="stunv4.7.supertuxkart.net:3478" ping="0"/>
    <stun-server address="stunv4.8.supertuxkart.net:3478" ping="0"/>
    <stun-server address="stun.l.google.com:19302" ping="0"/>
    <!--stun-server address="stunv4.linuxreviews.org:3478" ping="0"/-->
</ipv4-stun-servers>

<!-- The stun servers that will be used to know the public address (including ipv6) with port -->
<ipv6-stun-servers>
    <!--stun-server address="stun.linuxreviews.org:3478" ping="0"/-->
    <stun-server address="stun.stunprotocol.org:3478" ping="0"/>
    <stun-server address="stun.supertuxkart.net:3478" ping="0"/>
    <stun-server address="stun.l.google.com:19302" ping="0"/>
</ipv6-stun-servers>
@kimden
Copy link
Contributor Author

kimden commented Jun 20, 2024

After a few months, I realized there's an option default-ip-type in network settings of config.xml, setting which to dual stack instead of auto detect seems to solve most of my problems with multiple restarts. I'll comment/edit this if that's not true later, but the difference is already huge and I don't have to spend as much time as before.

I guess this makes the issue even more minor, because a server host can just determine the type of network once and then change the config. However, if there are plans in the future to investigate how this happens (otherwise I guess it should be closed), I gathered some stats from when I tried to restart the servers. They are below.


I made 294 attempts to start a server for it to be dual-stack, as follows: start the server, if it doesn't have dual stack network, repeat the procedure (or stop it, in 15 cases). Most server restart attempts were grouped together (when I restarted all the servers), their results could be dependent in some way. There were 839 server runs in total.

419 (50%) runs ended up detecting only IPv4.
139 (17%) runs ended up detecting only IPv6.
281 (33%) runs detected both.

Of 279 attempts ending with server having dual-stack network, 39% finished after one run, 57% - after at most two, 70% - after at most three runs. 8% attempts took at least 7 runs, and in two occasions, it took 11 and 12 restarts, respectively.

The 2.x server which used a different config folder failed to detect dual-stack network only once. Generally it seems like servers which are less used have a better dual-stack detection rate.

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

No branches or pull requests

2 participants