"on_replication_start" Error due to missing NetworkID, but NetworkID can be printed and remote scene inspector shows correct authority?

Godot Version

4.3

Question

I’m working very closely to this blog post: Multiplayer in Godot 4.0: Scene Replication – Godot Engine

The error only shows for the clients (for each client that spawns) and seems to have no impact on the final authority of the node on server or client. The error is:

E 0:00:03:0677   on_replication_start: The MultiplayerSynchronizer at path "/root/Lobby/Spawns/1822449508/PlayerInput" is unable to process the pending spawn since it has no network ID. This might happen when changing the multiplayer authority during the "_ready" callback. Make sure to only change the authority of multiplayer synchronizers during "_enter_tree" or the "_spawn_custom" callback of their multiplayer spawner.
  <C++ Error>    Condition "pending_sync_net_ids.is_empty()" is true. Returning: ERR_INVALID_DATA
  <C++ Source>   modules/multiplayer/scene_replication_interface.cpp:243 @ on_replication_start()

Working backwards from the error, this is the important part of the PlayerInput node script (I tested commenting out the rest of the script too) - also g.log is just a print() wrapper that prepends multiplayer.get_unique_id():

func _enter_tree() -> void:
    g.log(">>Setting multiplayer authority to %s" % [str(get_parent().player_id)])
    g.log(">>Network ID is %s" % [str(multiplayer.get_unique_id())])
    g.log(">>Multiplayer Authority Before is %s" % [str(get_multiplayer_authority())])
    set_multiplayer_authority(get_parent().player_id)
    g.log(">>Multiplayer Authority After is %s" % [str(get_multiplayer_authority())])

This is the output when the player is spawned:

{1} >>Setting multiplayer authority to 1822449508
{1} >>Network ID is 1
{1} >>Multiplayer Authority Before is 1
{1} >>Multiplayer Authority After is 1822449508
...
{1822449508} >>Setting multiplayer authority to 1822449508
{1822449508} >>Network ID is 1822449508
{1822449508} >>Multiplayer Authority Before is 1
{1822449508} >>Multiplayer Authority After is 1822449508

Here is the code that is doing the player spawning (spawns is the node registered with the MultiplayerSpawner’s SpawnPath):

func add_player(peer_id):
	var player = Player.instantiate()
	player.player_id = peer_id
	player.name = str(peer_id)
	spawns.add_child(player, true)

Some other Notes:

  • Removing the set_multiplayer_authority() line removes the error - so that is the source line
  • When the PlayerInput node is selected in the Remote Scene viewer, the Inspector shows the correct MultiplayerAuthority for server and clients.
  • I haven’t done much testing but it seems like this error is doing nothing? (I would hate to move forward without first understanding this error)

Thanks for reading! Please let me know if there is any more info I can provide. I’m curious if anyone else has seen this and I’ll update if I find out more. If no one knows I can try to put together a micro example tomorrow or the next day.

1 Like

Ok, still no luck :frowning: I’ve created a micro example if anyone wants to try, you only need to make two scenes:

Lobby.tscn (default start scene)

  • Add MultiplayerSynchronizer as child of this Node
  • Add Node as child, name it Spawns
  • Add the following script to the Lobby:
extends Node

@onready var spawns: Node = $Spawns
@onready var spawner: Node = $MultiplayerSpawner

const PORT = 7000
const DEFAULT_SERVER_IP = "127.0.0.1"
var Player = preload("res://player.tscn")

func _ready() -> void:
    spawner.spawn_path = spawns.get_path()
    spawner.add_spawnable_scene("res://player.tscn")
    create_buttons()

func create_game():
    print('Creating Game')
    var peer = ENetMultiplayerPeer.new()
    peer.create_server(PORT)
    multiplayer.multiplayer_peer = peer
    multiplayer.peer_connected.connect(add_player)

func join_game():
    print('Joining Game')
    var peer = ENetMultiplayerPeer.new()
    peer.create_client(DEFAULT_SERVER_IP, PORT)
    multiplayer.multiplayer_peer = peer

func add_player(peer_id):
    print('Adding Player, Peer ID: %s' % [str(peer_id)])
    # await get_tree().create_timer(2.0).timeout
    # print('Timeout Done')
    var player = Player.instantiate()
    player.name = str(peer_id)
    spawns.add_child(player, true)

func create_buttons():
    var vbox = VBoxContainer.new()
    add_child(vbox)

    var host_button = Button.new()
    host_button.text = "HOST"
    host_button.connect("pressed", create_game)
    vbox.add_child(host_button)

    var join_button = Button.new()
    join_button.text = "JOIN"
    join_button.connect("pressed", join_game)
    vbox.add_child(join_button)

player.tscn

  • Add MultiplayerSynchronizer as child
  • Add this script to the MultiplayerSynchronizer:
extends MultiplayerSynchronizer

func _enter_tree() -> void:
    print("NetID: %s is setting multiplayer authority to %s" % [str(multiplayer.get_unique_id()), str(get_parent().name)])
    set_multiplayer_authority(get_parent().name.to_int())
    print("NetID: %s sees authority: %s" % [str(multiplayer.get_unique_id()), str(get_multiplayer_authority())])

Now to test it:

  • Be sure to set: Debug → Customize Run Instances… → Check “Enable Multiple Instances” → Set to 2+
  • Host on 1, join on the other, check the output

You should see an error like:

E 0:00:06:0613   on_replication_start: The MultiplayerSynchronizer at path "/root/Lobby/Spawns/676522849/MultiplayerSynchronizer" is unable to process the pending spawn since it has no network ID. This might happen when changing the multiplayer authority during the "_ready" callback. Make sure to only change the authority of multiplayer synchronizers during "_enter_tree" or the "_spawn_custom" callback of their multiplayer spawner.
  <C++ Error>    Condition "pending_sync_net_ids.is_empty()" is true. Returning: ERR_INVALID_DATA
  <C++ Source>   modules/multiplayer/scene_replication_interface.cpp:243 @ on_replication_start()

and output in the terminal like:

Creating Game
Joining Game
Adding Player, Peer ID: 622658096
NetID: 1 is setting multiplayer authority to 622658096
NetID: 1 sees authority: 622658096
NetID: 622658096 is setting multiplayer authority to 622658096
NetID: 622658096 sees authority: 622658096

And if you inspect the MultiplayerSynchronizer node in the Scene → Remote panel, both sessions will show the correct authority.

There must be a correct way to do this - anyone know?

If no one else knows, should I take this to Github and open an issue?

Update: I made a post on the github (`modules/multiplayer/scene_replication_interface` @243 throws error perhaps change this check to a warning? · Issue #98104 · godotengine/godot · GitHub)

Looks like its being treated as an error that should be a warning. So for anyone who sees this, it can probably be ignored (though I will update if it turns out something wasn’t working behind the scenes)

One more note, this error only seems to happen when the authority of a MultiplayerSynchronizer node is changed, not base Node.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.