FSocket Connection breaks

I am using an Fsocket to receive data from a remote client. The socket is setup much the same way as in this example:
A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums,Receive_Binary_Data_From_an_IP/Port_Into_UE4,(Full_Code_Sample)

I am now only testing over localhost/127.0.0.1 and receiving data from a python script.
The data is recieved when a user presses a key and the function TCPReceiveData, listed below, is called.

TArray<uint8> ANetwork::TCPReceiveData(uint32 BytesToRead)
{
	if (!ConnectionSocket) {
		return TArray<uint8>();
	} else if ( ConnectionSocket == (FSocket*)0xdddddddddddddddd) {
		return TArray<uint8>();
	}
	
	TArray<uint8> ReceivedData;
	FTimespan BlockTime(0, 0, 5); // block wait for 5 secs
	if ( ConnectionSocket->Wait(ESocketWaitConditions::WaitForRead, BlockTime )) {
		ReceivedData.Init(BytesToRead);
		int32 Read = 0;
		ConnectionSocket->Recv(ReceivedData.GetData(), BytesToRead, Read);
	} else {
		return TArray<uint8>();
	}
	
	if (ReceivedData.Num() <= 0) {
		return TArray<uint8>();
	}
	
	return ReceivedData;
}

After reading from the socket anywhere between 10 and 50 times the connection breaks and it enters the following if statement:

if ( ConnectionSocket == (FSocket*)0xdddddddddddddddd) {
		UE_LOG(LogTemp, Log, TEXT("ConnectionSocket == 0xdddddddd"));
		return TArray<uint8>();
	}

And I cannot read from the socket anymore.
This happens very unregularly and I cannot for the life of me figure out how to solve this

It is possible that your Socket has been GC by the reflection system.