No owning connection for actor

"Hello everyone,

I’ve been studying Replication to add multiplayer functionality to a simple action game I’ve created. However, I’m encountering a ‘No owning connection for actor’ warning, but the function being Executed. (This could be because I’m running it in PIE (Play-In-Editor) mode)
However, the Replicate function executed in BeginPlay does not take effect. For example, if you call SetRoleMode() in the BeginPlay function, only the server works, and the client does not respond. I’ve searched online and suggestions include checking the Owner or using Possess in PostLogin() using GameMode, but the issue remains unresolved. Both Player and Enemy use the same component.

Anyway, the important thing is that a warning appears every time the function is called, and I want to resolve this

In this context, I intend to make a specific AnimMontage play
when the space bar is pressed

Here is My Code

CPlayer.cpp

ACPlayer::ACPlayer()
{
	PrimaryActorTick.bCanEverTick = true;
	bReplicates = true;

	// CreateActorComponent
	CHelpers::CreateActorComponent(this, &Montages, "Montages");
	CHelpers::CreateActorComponent(this, &State, "State");
         // .... 
}
// Bind BeginPlay Function
void ACPlayer::OnEvade() 
{
State->SetRollMode();
}

void ACPlayer::Begin_Roll()
{
	bUseControllerRotationYaw = false;
	GetCharacterMovement()->bOrientRotationToMovement = true;

	FVector start = GetActorLocation();
	FVector end = start + GetVelocity().GetSafeNormal2D();

	SetActorRotation(UKismetMathLibrary::FindLookAtRotation(start, end));

	Montages->PlayRoll();
}
CStateComponent.h

private:
	UFUNCTION(Server, Reliable)
		void Server_ChangeStateType(EStateType InNewType, class AActor* DamageCauser = nullptr);
		void Server_ChangeStateType_Implementation(EStateType InNewType, class AActor* DamageCauser = nullptr);

		void ChangeType(EStateType InNewType, class AActor* DamageCauser = nullptr);
	UFUNCTION(NetMulticast, Reliable)
		void MC_ChangeStateType(EStateType InNewType, class AActor* DamageCauser = nullptr);
		void MC_ChangeStateType_Implementation(EStateType InNewType, class AActor* DamageCauser = nullptr);
CStateComponent.cpp

void UCStateComponent::SetRollMode()
{
	ChangeType(EStateType::Roll);
}
void UCStateComponent::ChangeType(EStateType InNewType, AActor* DamageCauser)
{
	Server_ChangeStateType(InNewType, DamageCauser);
}
void UCStateComponent::MC_ChangeStateType_Implementation(EStateType InNewType, AActor* DamageCauser)
{
	EStateType prevType = Type;
	Type = InNewType;
	if (OnStateTypePreChanged.IsBound())
		OnStateTypePreChanged.Broadcast(prevType, Type, DamageCauser);

	if (OnStateTypeChanged.IsBound())
		OnStateTypeChanged.Broadcast(prevType, Type, DamageCauser);
}
OnStateTypeChanged Delegate Call ACPlayer::Begin_Roll()
And Function Call Montages->PlayRoll();

The following is same in flow and state to the existing one. PlayRoll() calls Server_PlayAnimMontage(), which in turn calls MC_PlayAnimMontage() 
to propagate it to the clients

If there is not enough explanation for this code, you can check it on this GitHub.
Github Code

What steps should I take to resolve this issue, eliminate the warning, and get the replication working?

Thank you."

I think this warning is because you are trying to execute this functions in the cliente side.

or

Did you try to declare this function inside of the controller code?

The client is the controller owner so maybe you can execute it without problems.

Take a look of this:

If your code is on the PAWN… maybe you can use de HasAuthority() function to avoid execute it in the client side

Although it was resolved using HasAuthority(), I have a question.
First of all, the Component is indeed located in the Pawn.
What I intended was to call for the Server function from the client side and, in that situation, propagate it to other clients via multicast.
However, by using HasAuthority(), doesn’t it mean that the function call the Server function from the client side is not being transmitted? Or is it because the Pawn exists on the server as well, so functions executed on the client are automatically propagated without any special replication measures?

The main pawn is in the server… the client have a copy… so it is replicated on the client.

Basicly that is replication… copy in the cliente what happen in the server… So the RPC’s only can be executed by the server.

nope… see the image i posted… you are handling both sides in the same time :wink:

After listening to your explanation, I revisited the code and realized that there was a call to the Server function(Server_ChangeType) from within the Multicast function(MC_SetMode). Now I understand, thank you.

1 Like

You are wellcome!! :ok_hand:t5:

This is incorrect. Replicated variables is when a variable is being replicated from the Server to a Client however a Server RPC is the exception where it allows a Client to call a function on the Server.

Clients can only call Server RPC’s from an Actor they are the NetOwner of otherwise you will get the warning in the log “No owning connection for actor” and the call will be dropped.

The purpose of Remote Procedure Calls is that you call it on one entity and it gets executed on another similar to a Remote Control and a TV. You press the power On button on the remote control but it is the TV that execute the function and turn itself on.

1 Like

That’s right, I forgot that. That is why the client can communicate with the server using the controller.
Thank you for the correction.

Excellent analogy. Thanks for the clarification.

1 Like

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