godot: MultiplayerSynchronizer and RPCs lead to errors on the server when a client disconnects
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
4.0-beta9
System information
Windows 11
Issue description
Using the MultiplayerSynchronizer node, or sending RPCs every frame, leads to errors in the server’s console when there are multiple clients and one of them disconnects. It seems that increasing the Replication Interval of the MultiplayerSynchronizer or sending RPCs less frequently makes the problem less likely to occur, but it still will happen occasionally.
I wasn’t able to find an existing open issue for this, which is strange given how easy the issue is to encounter (at least in my testing). So, I may have been searching with the wrong keywords.
Here is an example of the type of errors produced:
ERROR: Condition "peer > 0 && !connected_peers.has(peer)" is true.
at: _process_sys (modules/multiplayer/scene_multiplayer.cpp:317)
ERROR: Node not found: "World/Players/70163785" (relative to "/root").
at: (scene/main/node.cpp:1359)
ERROR: Failed to get cached path: World/Players/70163785.
at: get_cached_object (modules/multiplayer/scene_cache_interface.cpp:246)
ERROR: Invalid packet received. Requested node was not found.
at: (modules/multiplayer/scene_rpc_interface.cpp:228)
ERROR: Condition "peer > 0 && !connected_peers.has(peer)" is true.
at: _process_sys (modules/multiplayer/scene_multiplayer.cpp:317)
Steps to reproduce
The problem generally seems to occur under the following scenario:
- Use a MultiplayerSynchronizer node to synchronize a variable that the client has authority over. Alternatively, send a consistent stream of RPCs from one of the clients. (Both of these happen in the example).
- Start a server, connect multiple clients.
- Close one of the clients.
- Errors will appear in the console of the server.
Repeating these steps multiple times may lead to slightly different output, but the general errors are the same.
Minimal reproduction project
Start one instance of the game with the “–server” flag. Start two or more other instances without the server flag, these are the clients. Close one of the clients. Errors are then printed in the server’s console.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 33 (10 by maintainers)
Commits related to this issue
- Try: Fix error if one peer disconnect if multiple client connected ===: See issue https://github.com/godotengine/godot/issues/70505 ===: https://github.com/godotengine/godot/blob/6ba017968270c41e2de6b... — committed to Fox-Alpha/Godot-4-Roguelike-Multiplayer by Fox-Alpha 3 years ago
- feat: adding Singleton to the project and fixing bug by updating the project to godot v4.3 fixing the bug: https://github.com/godotengine/godot/issues/70505 — committed to devmoreir4/godot-3d-multiplayer-template by devmoreir4 2 years ago
I’d be inclined towards making these use
print_verbose().I get this error on 4.1.1.
In my opinion these cases (at least for my use case) shouldn’t be considered errors, so I made the following changes locally.
Code diff
Personally, I don’t think there should be errors logged due to using NetworkSynchronizer in what I believe is the intended way. RPCs sent to nodes that have just been destroyed by a client disconnecting should also be simply ignored in my opinion. However, I don’t have enough context on the networking system as a whole to be sure that the changes I made here don’t cause Godot to ignore actual errors. There might also be a very good reason to have errors in these situations that I’m not aware of.
@YuriSizov
Can confirm this problem still exists in Godot Engine v4.3.rc1.official.e343dbbcc
This error only occurs when there are multiple players connected to the server; if the last player leaves the game, there are no errors.
I don’t know if this will work for player synchronization, but for my bullets I currently bypassed it by setting the rootnode of the multiplayersynchronizer in the ready function to the parent where I know it would be.
func _ready(): $MultiplayerSynchronizer.set_root_path(“…/BulletSpawn”)
so far haven’t had the issues anymore (altho, limited testing) However, the error spam when despawning the bullets went away after I added it like that
I can confirm this is still present in latest master (68193bee9 as of writing).
Should I continue to provide feedback and the MRP here?
Can confirm this problem exists in v4.2.1.stable.official [b09f793f5] as well. Only happening on disconnect with more than one peer. (More than 2 if a player is the server.) It also happens multiple times that equal the remaining number of players who are not the server.
Just saw the bugsquad note at the top, sorry for the needless reconfirm, my bad.
Is there even a time when the error occurs as an actual mistake instead of by disconnecting?
Thank you very much. I have provided my minimal program and the steps to reproduce it in the previous reply, hoping it can help you.
Whoops, sorry for making you wait, I didn’t even work on it. I guess I could try figuring it out now. I just need more info.
The error log in the OP can be paraphrased as
"SceneMultiplayer has received an update for node World/Players/70163785 that does not exist (anymore) by a player that is not connected (anymore); update discarded".Most of the time, these logs are normal for networking. Sometimes, you are going to send an update, not knowing that either the pertaining player has already left, or the last updates by that leaving player are going to arrive after they alread left, and so on. Things have latency after all, and order of updates isn’t always guaranteed.
So most of the time, these are harmless (if you do not encounter any actual breakage). But sometimes, they can be indicative of a larger problem. If you get a lot of these suddenly after a change where you didn’t before, it is likely you got some ordering wrong somewhere, or some node paths are not matching up between clients, and so on.
So while it is noisy, sometimes it is useful. We may be able to trim them a bit, and may want to consider adding a way to silence them (optionally or by default).