SetOwner not working as expected

Hey there.

So I have the following Multiplayer Scenario: I have a multiplayer Session with an Actor I want to call RPCs on to Replicate some Mesh Data from the Server to a new joining Client. Currently, I do the following:

  • GameMode OnPostLogin
  • Call an Event (Sync LocalQuickShare) that is “Running on owning Client” on the newly joined Player Controller
  • Call an “Executes on Server” event from there.
  • This Event Sets the Owner the Actor in Question to the PlayerController of the new player (via a self-reference) and then calls a C++ function.
  • This C++ function should call a “Client”-Function, which itself should call a “Server”-Function of the Actor again.

This is, however, where it doesn’t work anymore. As soon as the Client-Function calls the Server-Function again, I get an Error message stating: No owning Connection for actor … Function ConfirmReplication will not be processed., which is not what I expected, since I set the Owner of the Actor to the Client.

Here is some of the Code:

DatasetExhibitor.h:

UFUNCTION(BlueprintCallable)
virtual void ReplicateDataToClient(const FString& DatasetPath);

UFUNCTION(Client, Reliable)
virtual void ReceiveVertices(const TArray<FVector>& Vertices, const FString& CheckSum);

UFUNCTION(Server, Reliable)
virtual void ConfirmReplication(const bool DataWasValid);

DatasetExhibitor.cpp:

void ADatasetExhibitor::ReplicateDataToClient(const FString& DatasetPath) {
    ...
    
    // Send the First Batch of Data
    TArray<FVector> Data = ...
    
    const FString Hash = FMD5::HashBytes((const uint8*) &Data[0], Data.GetAllocatedSize());
    ReceiveVertices(Data, Hash);
}


void ADatasetExhibitor::ReceiveVertices_Implementation(const TArray<FVector>& Vertices, const FString& CheckSum) {
    const FString Hash = FMD5::HashBytes((const uint8*) &Vertices[0], Vertices.GetAllocatedSize());

    if (Hash == CheckSum) {
        ReceivedVertices.Append(Vertices);
        ConfirmReplication(true);
    } else {
        ConfirmReplication(false);
    }
}


void ADatasetExhibitor::ConfirmReplication_Implementation(const bool DataWasValid) {
    ....
}

I thought that setting the Owner of the Actor to the Client where the Client-Functions are running on would make sure that calling a Server-Function wouldn’t be a problem, but apparently, that is not true.

Note: I only get the error about No owning Connection for actor … Function ConfirmReplication will not be processed. when I join the Session via a Second Computer. When I create the Session and the Computer is also the host, everything is working fine

Thanks in advance!

Small Additional Node: The Actor is already in the World when the Session is started and the owner is just changed everytime a new user joins!