diff --git a/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp b/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp index 122aaf8..889b963 100644 --- a/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp +++ b/Source/ROSIntegration/Private/ROSIntegrationGameInstance.cpp @@ -86,7 +86,7 @@ void UROSIntegrationGameInstance::Init() if (!bTimerSet) { bTimerSet = true; - GetTimerManager().SetTimer(TimerHandle_CheckHealth, this, &UROSIntegrationGameInstance::CheckROSBridgeHealth, 1.0f, true, 5.0f); + GetTimerManager().SetTimer(TimerHandle_CheckHealth, this, &UROSIntegrationGameInstance::CheckROSBridgeHealth, 5.0f, true, 5.0f); } if (bIsConnected) diff --git a/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp b/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp index 998c3d2..b176f92 100644 --- a/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp +++ b/Source/ROSIntegration/Private/rosbridge2cpp/TCPConnection.cpp @@ -39,9 +39,19 @@ bool TCPConnection::Init(std::string ip_addr, int port) std::cout << "Unable to set requested receiver buffer size" << std::endl; }*/ - if (!_sock->Connect(*addr)) + bool bConnected = false; + _sock->SetNonBlocking(true); + bConnected = _sock->Connect(*addr); + _sock->SetNonBlocking(false); + // If using _sock->Wait also blocks + if (bConnected ) //&& _sock->Wait(ESocketWaitConditions::WaitForWrite, FTimespan::FromSeconds(2))) + { + // do nothing + } + else + { return false; - + } // Setting up the receiver thread UE_LOG(LogROS, Display, TEXT("Setting up receiver thread ..."));