Connecting an actor to two different sockets

Hello I am working on a game and I am trying to add a wire to connect a powersource and drainer. In order to do this I thought it would be best to have sockets on both the powersource and drainer mesh and then corresponding sockets on the wire. Then attach the sockets. The code in the wire looks like this

void ABaseWire::ConnectPowerSource(FVector DrainerConnection, FVector SourceConnection, AItem* PowerSource, AItem* Drainer)
{
	SetSize((UKismetMathLibrary::Vector_Distance(DrainerConnection, SourceConnection)) / 100);
	SetActorLocation(DrainerConnection);
	Drainer->AttachWireToSelf(this, "DrainerSocket");
	SetActorRotation(UKismetMathLibrary::FindLookAtRotation(DrainerConnection, SourceConnection));
	PowerSource->AttachWireToSelf(this, "PowerSourceSocket");
	SetActorHiddenInGame(false);

	
}

And the attach to self function is called by the item here

void AItem::AttachWireToSelf(AItem* Wire, FName SocketName)
{
	const FTransform orientation_socket = Mesh->GetSocketTransform(SocketName, ERelativeTransformSpace::RTS_World);
	
	Wire->AttachToComponent(Mesh, FAttachmentTransformRules::SnapToTargetIncludingScale, SocketName);
}```

This code does not appear to work it will not show in game and obly be attached to the powersource when I look at the global actors.  How can I attach it to both sockets?

I don’t have an answer but I can explain why your code doesn’t work:

AttachToComponent: Attaches the RootComponent of this Actor to the supplied component, optionally at a named socket.

A component can only be attached to (at most) one other component. ie USceneComponent has an AttachParent property:

	UPROPERTY(ReplicatedUsing = OnRep_AttachParent)
	TObjectPtr<USceneComponent> AttachParent;

Ok thanks. I think what I’ll just do is only attach it to the power source, and set the rotation with some math. I was going to do that initially but I though this was easier. Thanks for the clarification.