cancel
Showing results for 
Search instead for 
Did you mean: 

Is it a bug that fail immediate reconnection with UE4 and OnlineSubsystemOculus?

mechamount
Explorer
Is this a bug in OnlineSubsystemOculus?

Steps to Reproduce

1. Create new project with OnlineSubsystemOculus.
2. Set project to CreateSession when c is pressed, JoinSession to the first Session found by FindSession when j is presssed,QuitGame when ESC is pressed.
3. Create windows package and place it on a separate windows PC.
4. Play with the sever side and press c to CreateSession.
5. Play with the client side and press j to JoinSession.
6. Press ESC to QuitGame if JoinSession succeeds on the client side.
7. Immediately press j on client side to recconect.

Results

Occasionally, JoinSession succeeds but connection fails with PendingConnectionFailure.


Expected

Connection succeeds.

Description

If the connection fails, the server logs the following.
[2020.01.31-05.58.18:173][ 56]LogNet: Verbose: 1433034680154146 changed network connection state
[2020.01.31-05.58.18:173][ 56]LogNet: Warning: Cannot reopen a closed connection to 1433034680154146
If the connection fails, The following server log is recorded when disconnecting the previous connection.
[2020.01.31-05.57.57:206][909]LogNet: UChannel::CleanUp: ChIndex == 0. Closing connection. [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 1433034680154146.oculus, Name: OculusNetConnection_2147482424, Driver: GameNetDriver OculusNetDriver_2147482539, IsServer: YES, PC: PlayerController_2147482420, Owner: PlayerController_2147482420, UniqueId: Oculus:ovrID:1433034680154146
[2020.01.31-05.57.57:206][909]LogNet: Verbose: UNetConnection::SetClientLoginState: State changing from ReceivedJoin to CleanedUp
If the connection succeeds, the following server log recorded when disconnecting the previous connection.
[2020.01.31-05.57.29:442][756]LogNet: UChannel::CleanUp: ChIndex == 0. Closing connection. [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 1433034680154146.oculus, Name: OculusNetConnection_2147482453, Driver: GameNetDriver OculusNetDriver_2147482539, IsServer: YES, PC: PlayerController_2147482449, Owner: PlayerController_2147482449, UniqueId: Oculus:ovrID:1433034680154146
[2020.01.31-05.57.29:442][756]LogNet: Verbose: UNetConnection::SetClientLoginState: State changing from ReceivedJoin to CleanedUp
[2020.01.31-05.57.38:324][ 88]LogNet: Verbose: UNetConnection::SetClientLoginState: State same: CleanedUp
When the connection is successful, "UNetConnection::SetClientLoginState: State same: CleanedUp" is recorded when the previous connection is disconnected.
Upon examination, it appeared that this log was being called by UOculusNetConnection::FinishDestroy.
I think that if I connect before the previous Connection is destoried by garbage collect, the connection will fail.

The following fix worked for me.

diff --git a/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetConnection.h b/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetConnection.h
index d482315..d0cc5bb 100644
--- a/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetConnection.h
+++ b/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetConnection.h
@@ -29,6 +29,7 @@ public:
FString LowLevelGetRemoteAddress(bool bAppendPort = false) override;
FString LowLevelDescribe() override;
virtual void FinishDestroy() override;
+ virtual void CleanUp() override;^M virtual FString RemoteAddressToString() override;
// End NetConnection Interface
diff --git a/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetDriver.h b/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetDriver.h
index b894646..158f5fa 100644
--- a/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetDriver.h
+++ b/Plugins/Online/OnlineSubsystemOculus/Source/Classes/OculusNetDriver.h
@@ -45,4 +45,6 @@ public:
void OnNewNetworkingPeerRequest(ovrMessageHandle Message, bool bIsError); void OnNetworkingConnectionStateChange(ovrMessageHandle Message, bool bIsError);
+^M
+ bool RemoveConnection(uint64 PeerID);^M
};
diff --git a/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetConnection.cpp b/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetConnection.cpp
index 880db83..f750de5 100644
--- a/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetConnection.cpp
+++ b/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetConnection.cpp
@@ -1,6 +1,7 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. #include "OculusNetConnection.h"
+#include "OculusNetDriver.h"^M
#include "OnlineSubsystemOculusPrivate.h" #include "IPAddressOculus.h"
@@ -156,6 +157,21 @@ void UOculusNetConnection::FinishDestroy()
}
}+void UOculusNetConnection::CleanUp()^M
+{^M
+ if (bIsPassThrough)^M
+ {^M
+ UIpConnection::CleanUp();^M
+ return;^M
+ }^M
+^M
+ if (Driver != nullptr)^M
+ {^M
+ reinterpret_cast<UOculusNetDriver*>(Driver)->RemoveConnection(PeerID);^M
+ }^M
+ UNetConnection::CleanUp();^M
+}^M
+^M
FString UOculusNetConnection::RemoteAddressToString()
{
if (bIsPassThrough)
diff --git a/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetDriver.cpp b/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetDriver.cpp
index ee5be0f..73a3789 100644
--- a/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetDriver.cpp
+++ b/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetDriver.cpp
@@ -513,3 +513,15 @@ bool UOculusNetDriver::IsNetResourceValid()
// The clients need to wait until the connection is established before sending packets
return ServerConnection->State == EConnectionState::USOCK_Open;
}
+^M
+bool UOculusNetDriver::RemoveConnection(uint64 PeerID)^M
+{^M
+ if (!Connections.Contains(PeerID))^M
+ {^M
+ UE_LOG(LogNet, Warning, TEXT("Connections doesn't have the PeerID"))^M
+ return false;^M
+ }^M
+^M
+ Connections.Remove(PeerID);^M
+ return true;^M
+}















5 REPLIES 5

mechamount
Explorer
I use UE4.24.3.

Anonymous
Not applicable
Bump, I just got the same info in the output log and the client wasn't able to [initially] connect.

Unreal Engine 4.24.3 (Launcher)

1917 zulu
I copied the oculus plugin to my project and made the suggested modifications and hopefully I did everything right, but I was still getting a connection time out.

mechamount
Explorer
I have also made the following changes to OnlineSubsytemOculus.
==============================================
https://issues.unrealengine.com/issue/UE-82549
==============================================

Otherwise I could not connect.






Any luck getting this to work with 4.27?

staniekmarcin
Protege

bump for 4.27? Does anyone have a fix?