Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC is being discarded if non-hosts aren't ready when the host invokes the method #6

Open
qwbarch opened this issue Apr 12, 2024 · 4 comments

Comments

@qwbarch
Copy link

qwbarch commented Apr 12, 2024

The problem

If an RPC method is called from the host while the client isn't ready (the object doesn't exist yet), the RPC call is discarded.

What I expect to happen

If the object doesn't exist on a non-host's client, I'd expect it to still eventually work.
My guess at a naive fix to this is to implement some sort of retry mechanism. One issue however, is the fact that in this case it needs to trust other clients are just trying to invoke an RPC method on a game object that isn't ready yet.
If it takes in every request and retries for awhile, clients are prone to being DOS'ed.

What actually happens

The RPC call gets discarded.

How do I reproduce this issue?

  1. git clone https://github.com/qwbarch/cw-rpc-reproducible
  2. cd cw-rpc-reproducible && dotnet build FooBar.csproj

Assuming you have UnityExplorer, head down the ship on two clients and then spawn an enemy manually by doing the following (via the host):

  1. Click on C# console.
  2. Type MonsterSpawner.SpawnMonster("zombe"), and then press ctrl + r to spawn the enemy.

You will notice two things on the non-host client.

Naturally spawned enemies throw a mod id was not found exception:

System.Exception: The mod id 12345 was not found (loaded mods: )
  at MyceliumNetworking.MyceliumNetwork.GetMessageHandlers (System.UInt32 modID, System.String methodName) [0x00033] in ./MyceliumNetwork.cs:583
  at MyceliumNetworking.MyceliumNetwork.HandleMessage (MyceliumNetworking.Message message, Steamworks.CSteamID sender) [0x00000] in ./MyceliumNetwork.cs:591    at MyceliumNetworking.MyceliumNetwork.GetMessageHandlers (System.UInt32 modID, System.String methodName) [0x00033] in ./MyceliumNetwork.cs:583
  at MyceliumNetworking.MyceliumNetwork.HandleMessage (MyceliumNetworking.Message message, Steamworks.CSteamID sender) [0x00000] in ./MyceliumNetwork.cs:591
[Error  :RugbugRedfern.MyceliumNetworking] Error executing RPC from 76561198860508656 (12345: SayHelloWorldRPC):

The manually spawned enemy (via unity explorer) results in a dropped RPC message:

[Warning:RugbugRedfern.MyceliumNetworking] Dropped RPC because no registered RPCs were found matching 12345: SayHelloWorldRPC
@RugbugRedfern
Copy link
Owner

Since the issue is not RPCs being received, but instead just not having anywhere to go after being received, I think a client side ordered buffer for RPCs would be a good solution - and then the buffered RPCs can be fired when the object is registered that matches their signature.

@qwbarch
Copy link
Author

qwbarch commented Apr 12, 2024

My only concern with buffering the RPC actions up until it's ready is, what's a safe way of doing this without making it prone to a DOS?
Since the object doesn't exist on the client side yet, simply holding a queue of every incoming RPC action sounds insecure.
Maybe there's a way to wait for a newly spawned proton network object to finish spawning? I know with unity netcode network objects you can do that, so I think that's worth exploring

@RugbugRedfern
Copy link
Owner

I don't really see how this would make anyone more viable to a DOS than just spamming them with valid RPCs? And waiting for the networked object to finish spawning is what the buffered RPC solution would be doing.

@qwbarch
Copy link
Author

qwbarch commented Apr 12, 2024

Nevermind scratch what I said about that, I was just thinking about a more naive solution. If there's a reliable way to wait for a photon network object to be ready on a client, that sounds like the way to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants