LAN game connection works when running on one computer but not when running on two different devices

Godot Version: 4.2.1

Hi there! I am having trouble with a game a I am working on. We are building a LAN connection system for users who are on the same network to be able to automatically start, and join a game together. This system seems to work great when running multiple instances on one computer, either in editor or as an exe. But as soon as I try to do it on two different computers we run into issues. Depending on which device is hosting sometimes the client will see the host and try to tun the add_player method, sometimes the client will just be unable to see the hosts broadcast at all and will never attempt to connect.

I am kinda at a loss here so would really appreciate some advice. I will include our main environment script which handles all the networking code at the moment. Thanks

extends Node3D

var peer = ENetMultiplayerPeer.new()
@export var player_scene: PackedScene

var broadcast_timer: Timer
var server_info = {"server_ip": "","player_count": 0}
var broadcaster : PacketPeerUDP
var listner : PacketPeerUDP
@export var listen_port : int = 9998
@export var broadcast_port : int = 9999
@export var broadcast_address : String = ''
var listener_ready: bool = false

signal server_found


func _ready():
	if Util.hosting and Util.LAN:
		_start_lan()
	if Util.joining and Util.LAN:
		_join_lan()
	if Util.hosting and Util.offline:
		_add_player()
	

func _process(_delta):
	if Input.is_action_just_pressed("esc"):
		Util.paused = not Util.paused
	if listener_ready:
		if listner.get_available_packet_count() > 0:
			var serverip = listner.get_packet_ip()
			var serverport = listner.get_packet_port()
			var bytes = listner.get_packet()
			var data = bytes.get_string_from_ascii()
			var roomInfo = JSON.parse_string(data)
			
			print("server Ip: " + serverip +" serverPort: "+ str(serverport) + " room info: " + str(roomInfo))
			if serverip != "" and roomInfo.player_count < 4:
				broadcast_address = serverip
				broadcast_port = serverport
				server_found.emit()
		else:
			#print("listner found no packet")
			pass

func _find_ip():
	var addresses = IP.get_local_addresses()
	for item in addresses:
		if item.contains("10.") or item.contains("192.168"):
			var index = item.rfind(".")
			if index != -1:
				server_info.server_ip = item
				item = item.substr(0, index + 1)
				return item + "255"

func _start_lan():
	broadcast_address = _find_ip()
	print("Broadcasting on address: " + broadcast_address)
	peer.set_bind_ip(server_info.server_ip)
	var error = peer.create_server(broadcast_port)
	if error != OK:
		print("cannot host: " + str(error))
		return
	multiplayer.multiplayer_peer = peer
	multiplayer.peer_connected.connect(_add_player)
	multiplayer.peer_disconnected.connect(_remove_player)
	_add_player()
	_set_up_broadcast()
	print("Waiting For Players!")

func _set_up_broadcast():
	server_info.player_count = 1
	broadcast_timer = $MultiplayerSpawner/BroadcastTimer
	broadcaster = PacketPeerUDP.new()
	broadcaster.set_broadcast_enabled(true)
	broadcaster.set_dest_address(broadcast_address, listen_port)
	
	var ok = broadcaster.bind(broadcast_port)
	
	if ok == OK:
		print("Bound to Broadcast Port "  + str(broadcast_port) +  " Successful!")
	else:
		print("Failed to bind to broadcast port!")
		print(ok)
		
	broadcast_timer.start()
	
func _add_player(peer_id = 1):
	print("adding player")
	var player = player_scene.instantiate()
	player.name = str(peer_id)
	call_deferred("add_child", player)
	server_info.player_count += 1
	print("player added")
	return player
	
func _remove_player(peer_id):
	var player = get_node_or_null(str(peer_id))
	if player:
		player.queue_free()
	server_info.player_count -= 1
		
func _join_lan():
	_set_up_listener()
	await server_found
	var join = peer.create_client(broadcast_address, broadcast_port)
	print("Join Error: " + str(join))
	multiplayer.multiplayer_peer = peer
	$MultiplayerSpawner/ConnectionTimer.stop()
	print('joined game')
	listener_ready = false

func _set_up_listener():
	listner = PacketPeerUDP.new()
	var ok = listner.bind(listen_port)
	
	if ok == OK:
		print("Bound to listen Port "  + str(listen_port) +  " Successful!")
		print("Bound To Listen Port: true")
		listener_ready = true
		$MultiplayerSpawner/ConnectionTimer.start()
	else:
		print("Failed to bind to listen port!")
		print("Bound To Listen Port: false")
		_return_to_menu()


func _on_broadcast_timer_timeout():
	print(server_info)
	var data = JSON.stringify(server_info)
	var packet = data.to_ascii_buffer()
	broadcaster.put_packet(packet)


func _on_connection_timer_timeout():
	_return_to_menu()

func _return_to_menu():
	multiplayer.multiplayer_peer = null
	Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
	get_tree().change_scene_to_file("res://ui/MainMenu.tscn")

Honestly not sure what happened, but it works now, no problem with no changes, so I guess problem solved? But I would like to try and know what was wrong for future reference.

PS: Your local address check is missing 172.16.xx.xx (on top of 10.xx.xx.xx and 192.168.xx.xx).