In multiplayer the send_auth returns error ERR_INVALID_PARAMETER and auth_callback dont execute

godot 4.3

this is my code for multiplayer with authentication:

func createServer()->void:
	var server_peer := ENetMultiplayerPeer.new()
	server_peer.create_server(port)
	multiplayer.multiplayer_peer = server_peer
	multiplayer.auth_callback = Callable(self, "_auth_request_handler")
	multiplayer.peer_authenticating.connect(_on_peer_authenticating)
	

func _auth_request_handler(peer_id: int, auth_data: PackedByteArray)->void:
	print(peer_id,auth_data)
	multiplayer.complete_auth(peer_id) 
	#multiplayer.disconnect_peer(peer_id)


func _on_peer_authenticating(peer_id:int)->void:
	print("Peer is authenticating: ", peer_id)



func joinServer()->void:
	var client_peer := ENetMultiplayerPeer.new()
	client_peer.create_client(ip,port)
	multiplayer.multiplayer_peer = client_peer
	multiplayer.peer_connected.connect (inClientSide_clientConnected)

func inClientSide_clientConnected(id:int)->void:
	
	if id==1:
		
		var auth_packet :PackedByteArray= "test".to_utf8_buffer()
		
		# Send the authentication data to the server
		var error = multiplayer.send_auth(id, auth_packet)
		print(id,auth_packet,error)

when client connects to server the function inClientSide_clientConnected will execute and will send auth data by multiplayer.send_auth(id, auth_packet) to server. this section will work without problem

in server when a client connects the function _on_peer_authenticating will execute without problem.

but after multiplayer.send_auth in client side, the function _auth_request_handler dont execute in server side for authenticating client.

the value of error in var error = multiplayer.send_auth(id, auth_packet) is 31 that means ERR_INVALID_PARAMETER

why ? is this a bug ?

hi. finally i found the solution.
i must use multiplayer.send_auth in signal function peer_authenticating in the client.
Now, if I want to emit peer_authenticating, I need to define a function for the auth_callback signal on the client side and also must send auth from server to client by peer_authenticating -> multiplayer.send_auth in server.
Then, at the end, I must to call multiplayer.complete_auth for id of server within the auth_callback in client.


extends Node

var port=8083
var ip='127.0.0.1'



func createServer()->void:
	var server_peer := ENetMultiplayerPeer.new()
	server_peer.create_server(port)
	multiplayer.multiplayer_peer = server_peer
	multiplayer.auth_callback =  _auth_request_handler_server
	multiplayer.peer_authenticating.connect(_on_peer_authenticating_server)
        multiplayer.peer_connected.connect(_on_peer_connected_server)
	


func _auth_request_handler_server(peer_id: int, auth_data: PackedByteArray)->void:
	print('_auth_request_handler_server: ',peer_id, " ", auth_data)
	multiplayer.complete_auth(peer_id)


func _on_peer_authenticating_server(peer_id:int)->void:
	
	print("Peer is authenticating (server): ", peer_id)
	var auth_packet :PackedByteArray= "response from server to client".to_utf8_buffer()
	var error = multiplayer.send_auth(peer_id, auth_packet)
	print(peer_id,'  ',error)


func _on_peer_connected_server(id: int) -> void:
	print("Connected (server): ", id)


func joinServer()->void:
	var client_peer := ENetMultiplayerPeer.new()
	client_peer.create_client(ip,port)
	multiplayer.multiplayer_peer = client_peer
	multiplayer.auth_callback = _auth_request_handler_client
	multiplayer.peer_authenticating.connect(_on_peer_authenticating_client)
        multiplayer.peer_connected.connect(_on_peer_connected_client)


func _auth_request_handler_client(peer_id: int, auth_data: PackedByteArray)->void:
	
	print('_auth_request_handler_client: ',peer_id, " ", auth_data)
	multiplayer.complete_auth(peer_id)


func _on_peer_authenticating_client(peer_id:int)->void:
	print("Peer is authenticating (client): ", peer_id)
	if peer_id==1:
                 var auth_packet :PackedByteArray= "authentication data to server".to_utf8_buffer()
	         var error = multiplayer.send_auth(peer_id, auth_packet)
	         print(peer_id,'  ',error)


func _on_peer_connected_client(id:int)->void:
	print("Connected (client): ", id)