Cant join match using Godot 3.5.3 and Nakama Server

I am trying to achieve loading a player into the gameworld using guidance from setup videos of yours and GDQuest on YouTube that worked yesterday and doesnt now.

So have followed tutorials on setting everything up to get a server running and registering, logging in, and joining etc. Yesterday I was able to join a match and test latency stuff etc and this morning I cannot join a match anymore. This is what prints out from the Nakama scripts somewhere:

=== Nakama : INFO === Connected!
=== Nakama : DEBUG === Sending async request: MatchJoin<match_id=ae81e606-837c-4650-b6e9-86eb5499fa75.nakama1, token=Null, metadata=Null>
=== Nakama : DEBUG === Resuming response: 1: {cid:1, error:{code:4, message:Match not found}}
=== Nakama : WARNING === Error response from server: {code:4, message:Match not found}

It wasnt doing that yesterday with zero changes in code. So, when I register and log in, I try to join (which is actually auto setup in the character selection script), but that prints now.

The relevant code that signals is from the CharacterSelector.gd:

func _on_loginBtn_pressed():
	var character_data: Dictionary = character_list.get_selected_character()
	if character_data.size() == 0:
		return
	emit_signal("login_pressed", character_data.name, character_data.color)

Im not sure what else I can add yet. Everything worked just fine yesterday. I also have had issues with token validation which is my other post recently so I dont know if they are related or not. Sorry if I seem ignorant. Im trying to learn the process and flow of connections still.

I narrowed some of it down to a function in the ServerConnection.gd. So I did some prints in

# Attempts to connect to the server, then to join the world match.
func join_game_world_async(player_name: String, player_color: Color) -> int:
	character_menu.is_enabled = false

	var result: int = yield(ServerConnection.connect_to_server_async(), "completed")
	if result == OK:
		result = yield(ServerConnection.join_world_async(), "completed")
		if result == OK:
			print('joining  game')
		else:
			print('cant join  game')
	else:
		print('cant join server')
	if result == OK:
		# warning-ignore:return_value_discarded
		get_tree().change_scene_to(load('res://scenes/3d/game.tscn'))
		ServerConnection.send_spawn(player_color, player_name)

	character_menu.is_enabled = true
	return result

and I get a print of ‘cant join game’. SO that comes from join_world_async() in the ServerConnection.gd. Which is here:

func join_world_async() -> int:
	if not _socket:
		error_message = "Server not connected."
		return ERR_UNAVAILABLE

	# Get match ID from server using a remote procedure
	if not _world_id:
		var world: NakamaAPI.ApiRpc = yield(
			_client.rpc_async(_authenticator.session, "get_world_id", ""), "completed"
		)

		var parsed_result := _exception_handler.parse_exception(world)
		if parsed_result != OK:
			return parsed_result

		_world_id = world.payload

	# Join world
	var match_join_result: NakamaRTAPI.Match = yield(
		_socket.join_match_async(_world_id), "completed"
	)
	var parsed_result := _exception_handler.parse_exception(match_join_result)

	if parsed_result == OK:
		for presence in match_join_result.presences:
			presences[presence.user_id] = presence

		# Join chat
		var chat_join_result: NakamaRTAPI.Channel = yield(
			_socket.join_chat_async("world", NakamaSocket.ChannelType.Room, false, false),
			"completed"
		)
		parsed_result = _exception_handler.parse_exception(chat_join_result)

		_channel_id = chat_join_result.id

	return parsed_result

Im trying to understand this part right now. There is a lot of back and forth with functions but if you see anything causing not finding match and why I suddenly cant join anymore from yesterday, let me know. I didnt change anything :confused:

I think it has something to do with modifying the lua script for world_control. I am using 3D, so I modified one of the dictionary keys for dir (direction in the player/character) to be a vector3 instead of a float (which was used for left and right in 2D). Not sure it likes that:

nakama-1 | {“level”:“warn”,“ts”:“2024-02-11T18:26:26.646Z”,“caller”:“server/match_handler.go:526”,“msg”:“Stopping match after error from match_join execution”,“mid”:“bdbcb946-9e43-4891-a56e-6dbc5546936c”,“tick”:0,“error”:“/nakama/data/modules/world_control.lua:108: attempt to index a non-table object(nil) with key ‘new’\nstack traceback:\n\t/nakama/data/modules/world_control.lua:108: in main chunk\n\t[G]: ?”}

Yes the issue is your match isn’t running anymore due to the error you just shared above. There is a bug in your Lua code where you are indexing into a nil object.

1 Like

Gotcha! I figured that was the issue because I am modifying the lua for additional information for stats :). Thank you!