widelands / widelands

Widelands is a free, open source real-time strategy game with singleplayer campaigns and a multiplayer mode. The game was inspired by Settlers II™ (© Bluebyte) but has significantly more variety and depth to it.
https://www.widelands.org/
GNU General Public License v2.0
2k stars 155 forks source link

LAN connection on same machine not working with named host #3973

Open gunchleoc opened 4 years ago

gunchleoc commented 4 years ago

Describe the bug During LAN testing on same machine, when I click on the games list, the server info doesn't reach the client. It does work when I connect to "localhost" instead.

To Reproduce Steps to reproduce the behavior:

  1. Host a LAN game
  2. Join the LAN game on same machine, selecting the game from the list

or:

  1. Host a LAN game
  2. Join the LAN game on same machine via the "Join this game" button with the server name in the text field

The problem goes away like this:

  1. Host a LAN game
  2. Join the LAN game on same machine via the "Join this game" button with "localhost" in the text field

Expected behavior Client should receive network communication from host and list the game settings.

Screenshots lan_connection

Version:

@Notabilis

Notabilis commented 4 years ago

Unfortunately I am unable to reproduce the problem even with the mentioned version. For me, all three approaches result in successful connections. Some ideas about how to debug this:

1) Is there any helpful output on the console? On a successful connect (by clicking the list entry) it writes on my system: [LAN] Started an IPv4 socket on UDP port 7394. [LAN] Started an IPv6 socket on UDP port 7394. [LAN] Will broadcast to 127.0.0.1. [LAN] Will broadcast to 192.168.1.255. [LAN] Will broadcast for IPv6. [Received GAME packet from 192.168.1.113 Received GAME packet from $ipv6address%$interface Received GAME packet from 192.168.1.113 Received GAME packet from $ipv6address%$interface Could not resolve network name '127.0.0.1:7396' to IPv6-address: resolve: Host not found (authoritative) Resolved network name '127.0.0.1:7396' to 127.0.0.1 [NetClient]: Trying to connect to ::1:7396 ... [BufferedConnection] Trying to connect to ::1:7396 ... success. success. [BufferedConnection] Starting networking thread [Client] SETTING_MAP 'Islands at War' 'maps/Islands_at_War.wmf' 2) Do you have IPv4 and/or IPv6 enabled and working correctly? 3) When you execute ping $yourhostname, which address is displayed? For me the output contains $myhostname (127.0.1.1). Are both ping -4 $yourhostname and ping -6 $yourhostname getting a response? 4) Is there a line like 127.0.1.1 $youhostname in /etc/hosts? 5) If you know how to use Wireshark (or tcp dump): Please capture the network traffic on the any interface with a capture filter of udp port 7394 or udp port 7395 or tcp port 7396 when you execute your three variants. Maybe its possible to see something going wrong there.

gunchleoc commented 4 years ago

Possibly related: https://github.com/widelands/widelands/issues/4367

Host log

[00:00:04.988 real] INFO: InternetGaming: Connecting to the metaserver.
[00:00:04.990 real] INFO: Resolved network name 'widelands.org:7395' to 2a03:4000:32:524:48cb:feff:feae:b0c6
[00:00:04.990 real] INFO: [NetClient]: Trying to connect to 2a03:4000:32:524:48cb:feff:feae:b0c6:7395 ... 
[00:00:04.990 real] INFO: [BufferedConnection] Trying to connect to 2a03:4000:32:524:48cb:feff:feae:b0c6:7395 ... 
[00:00:04.991 real] ERROR: failed.
[00:00:04.991 real] INFO: [BufferedConnection] Closing network socket.
[00:00:04.991 real] ERROR: failed.
[00:00:04.991 real] INFO: Resolved network name 'widelands.org:7395' to 85.235.66.69
[00:00:04.992 real] INFO: [NetClient]: Trying to connect to 85.235.66.69:7395 ... 
[00:00:04.992 real] INFO: [BufferedConnection] Trying to connect to 85.235.66.69:7395 ... 
[00:00:05.041 real] INFO: success.
[00:00:05.041 real] INFO: success.
[00:00:05.041 real] INFO: InternetGaming: Sending login request.
[00:00:05.041 real] INFO: [BufferedConnection] Starting networking thread
[00:00:05.102 real] INFO: InternetGaming: Client GunChleoc1 logged in at UTC Fri Oct 16 08:18:41 2020
[00:00:05.102 real] INFO: InternetGaming: Server time offset is 0 second(s).
[00:00:05.117 real] INFO: [LAN] Started an IPv4 socket on UDP port 7394.
[00:00:05.117 real] INFO: [LAN] Started an IPv6 socket on UDP port 7394.
[00:00:05.117 real] INFO: [LAN] Will broadcast to 127.0.0.1.
[00:00:05.117 real] INFO: [LAN] Will broadcast to 192.168.0.255.
[00:00:05.117 real] INFO: [LAN] Will broadcast for IPv6.
[00:00:07.812 real] INFO: [Host]: starting up.
[00:00:07.812 real] INFO: [NetHost] Opening a listening IPv6 socket on TCP port 7396
[00:00:07.812 real] INFO: [NetHost] Starting to listen for network connections
[00:00:07.813 real] INFO: [NetHost] Starting networking thread
[00:00:07.813 real] INFO: [LAN] Started an IPv4 socket on UDP port 7395.
[00:00:07.813 real] INFO: [LAN] Started an IPv6 socket on UDP port 7395.
[00:00:07.813 real] INFO: [LAN] Will broadcast to 127.0.0.1.
[00:00:07.813 real] INFO: [LAN] Will broadcast to 192.168.0.255.
[00:00:07.813 real] INFO: [LAN] Will broadcast for IPv6.
[00:00:09.625 real] INFO: Registering the world took 28ms
[00:00:10.491 real] INFO: WidelandsMapLoader::load_map_for_render() for 'Glacier Lake' took 43ms
[00:00:10.789 real] WARNING: Map/Save is a directory! No way for making it available a.t.m.!
[00:00:10.791 real] DEBUG: lastserial: 0
[00:00:22.211 real] ERROR: [BufferedConnection] Error when receiving data from host (error 2: End of file)
[00:00:22.211 real] ERROR: [BufferedConnection] Closing socket
[00:00:22.211 real] INFO: [BufferedConnection] Stopping networking thread
[00:00:22.273 real] INFO: Received QUERY packet from 127.0.0.1

Client log

[00:00:04.596 real] INFO: InternetGaming: Connecting to the metaserver.
[00:00:04.596 real] INFO: Resolved network name 'widelands.org:7395' to 2a03:4000:32:524:48cb:feff:feae:b0c6
[00:00:04.596 real] INFO: [NetClient]: Trying to connect to 2a03:4000:32:524:48cb:feff:feae:b0c6:7395 ... 
[00:00:04.596 real] INFO: [BufferedConnection] Trying to connect to 2a03:4000:32:524:48cb:feff:feae:b0c6:7395 ... 
[00:00:04.596 real] ERROR: failed.
[00:00:04.596 real] INFO: [BufferedConnection] Closing network socket.
[00:00:04.597 real] ERROR: failed.
[00:00:04.597 real] INFO: Resolved network name 'widelands.org:7395' to 85.235.66.69
[00:00:04.597 real] INFO: [NetClient]: Trying to connect to 85.235.66.69:7395 ... 
[00:00:04.597 real] INFO: [BufferedConnection] Trying to connect to 85.235.66.69:7395 ... 
[00:00:04.646 real] INFO: success.
[00:00:04.646 real] INFO: success.
[00:00:04.646 real] INFO: [00:00:04.646 real] INFO: InternetGaming: Sending login request.
[BufferedConnection] Starting networking thread
[00:00:07.740 real] INFO: InternetGaming: Client GunChleoc1 logged in at UTC Fri Oct 16 08:18:58 2020
[00:00:07.740 real] INFO: InternetGaming: Server time offset is 0 second(s).
[00:00:07.757 real] INFO: [LAN] Started an IPv4 socket on UDP port 7394.
[00:00:07.757 real] INFO: [LAN] Started an IPv6 socket on UDP port 7394.
[00:00:07.757 real] INFO: [LAN] Will broadcast to 127.0.0.1.
[00:00:07.757 real] INFO: [LAN] Will broadcast to 192.168.0.255.
[00:00:07.757 real] INFO: [LAN] Will broadcast for IPv6.
[00:00:07.824 real] INFO: Received GAME packet from 127.0.0.1
[00:00:09.243 real] INFO: [NetClient]: Trying to connect to 127.0.0.1:7396 ... 
[00:00:09.243 real] INFO: [BufferedConnection] Trying to connect to 127.0.0.1:7396 ... 
[00:00:09.243 real] INFO: success.
[00:00:09.243 real] INFO: success.
[00:00:09.243 real] INFO: [BufferedConnection] Starting networking thread
[00:00:37.948 real] ERROR: [BufferedConnection] Error when receiving data from host (error 2: End of file)
[00:00:37.948 real] ERROR: [BufferedConnection] Closing socket
[00:00:37.948 real] INFO: [BufferedConnection] Stopping networking thread

Ping

$ ping $hostname
PING $hostname (127.0.1.1) 56(84) bytes of data.
64 bytes from $hostname (127.0.1.1): icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=2 ttl=64 time=0.053 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=3 ttl=64 time=0.059 ms

$ ping -4 $hostname
PING $hostname (127.0.1.1) 56(84) bytes of data.
64 bytes from $hostname (127.0.1.1): icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=2 ttl=64 time=0.059 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=3 ttl=64 time=0.062 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=4 ttl=64 time=0.061 ms
64 bytes from $hostname (127.0.1.1): icmp_seq=5 ttl=64 time=0.062 ms

$ ping -6 $hostname
connect: Invalid argument

etc/hosts

$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   $hostname

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Niektory commented 3 years ago

I can't reproduce this problem in 1.0~git24947[870c1e1@master] (Debug).