Error when replicating variables

Hi all!

TL;DR - When server changes a replicated variable, client disconnects with Error: ReceivedBunch: Invalid replicated field 0 in TemplatePawn_C

This is code in my TemplatePawn that updates position of avatar of VR headset. It’s an adaptation of Collab Viewer template and its BP_VRPawn.



LogPlayLevel: Error: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogRep: Error: ReceivedBunch: Invalid replicated field 0 in TemplatePawn_C /Game/Debugging/Levels/MultiplayerLevel.MultiplayerLevel:PersistentLevel.TemplatePawn_C_2147482317
LogPlayLevel: Error: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogNet: Error: UActorChannel::ProcessBunch: Replicator.ReceivedBunch failed.  Closing connection. RepObj: TemplatePawn_C /Game/Debugging/Levels/MultiplayerLevel.MultiplayerLevel:PersistentLevel.TemplatePawn_C_2147482317, Channel: 5
LogPlayLevel: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: 192.168.0.102:7777, Name: IpConnection_2147482375, Driver: Name:GameNetDriver Def:GameNetDriver IpNetDriver_2147482438, IsServer: NO, PC: BP_CollabPlayerController_C_2147482326, Owner: BP_CollabPlayerController_C_2147482326, UniqueId: NULL:localhost-AC3812865DD34F9EB0C7297DCB55A015, Channels: 6, Time: 2024.10.24-11.06.15
LogPlayLevel: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogNet: UNetConnection::SendCloseReason:
LogPlayLevel: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogNet:  - Result=ObjectReplicatorReceivedBunchFail, ErrorContext="ObjectReplicatorReceivedBunchFail"
LogPlayLevel: UAT: 10-24 13:06:15.588 17297 17475 D UE      : [2024.10.24-11.06.15:588][ 39]LogNet: UChannel::Close: Sending CloseBunch. ChIndex == 0. Name: [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 192.168.0.102:7777, Name: IpConnection_2147482375, Driver: Name:GameNetDriver Def:GameNetDriver IpNetDriver_2147482438, IsServer: NO, PC: BP_CollabPlayerController_C_2147482326, Owner: BP_CollabPlayerController_C_2147482326, UniqueId: NULL:localhost-AC3812865DD34F9EB0C7297DCB55A015
LogPlayLevel: Error: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = Your connection to the host has been lost., Driver = Name:GameNetDriver Def:GameNetDriver IpNetDriver_2147482438
LogPlayLevel: Warning: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogNet: Warning: Network Failure: GameNetDriver[ConnectionLost]: Your connection to the host has been lost.
LogPlayLevel: Error: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogNet: NetworkFailure: ConnectionLost, Error: 'Your connection to the host has been lost.'
LogPlayLevel: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogBlueprintUserMessages: [BP_GameInstance_C_2147482575] ConnectionLost
LogPlayLevel: Warning: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogScript: Warning: Script Msg: DestroySession - Invalid player state
LogPlayLevel: Warning: UAT: 10-24 13:06:15.589 17297 17475 D UE      : [2024.10.24-11.06.15:589][ 39]LogScript: Warning: Script Msg called by: BP_GameInstance_C /Engine/Transient.GameEngine_2147482620:BP_GameInstance_C_2147482575
LogPlayLevel: Warning: UAT: 10-24 13:06:15.594 17297 17522 D UE      : [2024.10.24-11.06.15:594][ 40]LogHMD: Warning: Swapchain format not supported (50), falling back to runtime preferred format (43).

How it happens: I create a session on PC in editor and join it with HTC Vive Focus 3. As soon as EventUpdateCameraToServer is called, the client disconnects with errors above.

What I tried:

  • Don’t trigger it in EventTick and wait for couple of seconds after joining → error after wait period ended
  • Deleting Intermediate and Saved folders
  • Replicate only a new testing integer variable → same error

Workaround to use multicast RPC instead of replicating variables solved this. But I am reluctant to use it because I am not sure about performance of this solution. Especially if there would be many clients. And of course I will need variable replication for other functionality.

Does anyone have an insights on this?

Did you ever find a solution? I’m having the exact same issue after converting from UE4.27 to 5.4 and running both the packaged dedicated server/client on Windows.

might also add that moving the replication code for that particular class to C++ also didn’t fix the issue.
Replicating variables in other actor works without issues

Issue seemed to be with 5.4.4, adding NotReplicated to the AnimMontage_Deprecated in

Engine\Source\Runtime\Engine\Classes\GameFramework\Character.h
Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Public\Abilities\GameplayAbilityRepAnimMontage.h

fixed the issue:

UPROPERTY(NotReplicated, meta = (DeprecatedProperty, DeprecationMessage = "Use the GetAnimMontage function instead"))
	TObjectPtr<UAnimMontage> AnimMontage_DEPRECATED;

Also updating to 5.1 fixed the issue

shouldn’t be replicating animation in the first place. Replicate states, call specific events etc.