RPC '{method_name}' is not allowed on node /root/Server from: {peer_number}. Mode is 0, master is 1.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bizt

Here is the code that runs on the client after I’ve retrieved the authentication token:

func _ready():
	authenticate("username", "password")

func authenticate(username, password):
    http_request = HTTPRequest.new()
    http_request.connect("request_completed", self, "_http_request_completed")
    var body = JSON.print({
        "username": username,
        "password": password,
    http_request.request("https://httpbin.org/post", [], true, HTTPClient.METHOD_POST, body)

func _http_request_completed(result, response_code, headers, body):
	token = "1234567890qwertyuiop"

func connect_to_server():
	network.create_client(ip_address, port)
	network.connect("connection_failed", self, "_on_connection_failed")
	network.connect("connection_succeeded", self, "_on_connection_succeeded")

func _on_connection_succeeded():

func validate_token(token):
	rpc_id(1, "validate_token", token)

Here is the remote function that runs on the server:

remote func validate_token(token):
	var sender_id = get_tree().get_rpc_sender_id()
	# TODO query auth server with token 
	# disconnect peer if token not valid 
	if true:

However, it’s giving the following error on the server debug:

peer_connected: 1611028214
ERROR: RPC ‘validate_token’ is not allowed on node /root/Server from: 1611028214. Mode is 0, master is 1.
at: (core/io/multiplayer_api.cpp:285)

Strangely up until now other remote functions have worked fine. But it seems when I call them in this manner I get the error. I’ve tried other functions in place of validate_token that I know work later in the app, but they don’t work when called in this manner. It’s strange to me as I know the connection has been established, so I don’t know why it’s not calling the remote function.

:bust_in_silhouette: Reply From: Wakatta

This is quite simple.

You need to set the RPC mode for that function using either keywords ( remote, master, puppet) or rset("function", MODE)

A multiplayer checklist of you will.

  1. Who (which peers) will communicate
  2. Can they communicate (RPC modes set)
  3. How will they communicate (using what functions)
  4. What data will be exchanged ( recommend using the A sends to B and B verifies received to A model)