Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error callback in Realtime Client called several times #100

Closed
jsmidmfg opened this issue Aug 15, 2023 · 1 comment
Closed

Error callback in Realtime Client called several times #100

jsmidmfg opened this issue Aug 15, 2023 · 1 comment

Comments

@jsmidmfg
Copy link
Contributor

Hi, I found strange behaviour of the Listener from UNakamaRealtimeClient.
We use the same code for setup and connection of Realtime Client as here: Heroic Labs Documentation | Unreal | Nakama Socket

But, the OnRealtimeClientConnectionError() is called several times and our program crashes.

I found that the Realtime Client register the error callback here:

void UNakamaRealtimeClient::Connect(const FOnRealtimeClientConnected& Success, const FOnRealtimeClientError& Error)
{
	const NRtClientProtocol SelectedProtocol = static_cast<NRtClientProtocol>(Protocol);

...

	Listener.setErrorCallback([this, Error](const NRtError& Err)
	{
		UE_LOG(LogTemp, Warning, TEXT("Nakama Realtime Client Setup: Socket Connect Error"));
		Error.Broadcast();
	});

From my point of view, it’s a very unspecific callback for the Listener. Because different functions from Nakama SDK call OnError, and then our error delegate function is called.

void ASagiShiActor::OnRealtimeClientConnectionError()
{
    UE_LOG(LogTemp, Log, TEXT("Socket connection failed."));
}

There is my callstack:

UnrealEditor-NakamaUnreal-Win64-DebugGame.dll!Nakama::NRtDefaultClientListener::onError() [Nakama\Source\NakamaCore\Public\nakama-cpp\realtime\NRtDefaultClientListener.h:76]
nakama-sdk.dll!UnknownFunction
nakama-sdk.dll!UnknownFunction
UnrealEditor-NakamaCore-Win64-DebugGame.dll!std::_Func_class<void,std::basic_string<char,std::char_traits,std::allocator > const &>::operator()() [C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\INCLUDE\functional:862]
UnrealEditor-NakamaCore-Win64-DebugGame.dll!Nakama::NRtTransportInterface::fireOnMessage() [Nakama\Source\NakamaCore\Public\nakama-cpp\realtime\NRtTransportInterface.h:115]
UnrealEditor-NakamaCore-Win64-DebugGame.dll!Nakama::Unreal::UnrealWsTransport::tick() [Nakama\Source\NakamaCore\Private\websocket.cpp:120]
UnrealEditor-NakamaUnreal-Win64-DebugGame.dll!UNakamaRealtimeClient::Tick() [Nakama\Source\NakamaUnreal\Private\NakamaRealtimeClient.cpp:36]
UnrealEditor-Engine.dll!FTickableGameObject::TickObjects() [\Engine\Private\Tickable.cpp:153]

Possible solution
I suggest changing the error callback for UNakamaRealtimeClient::Connect(…). For example for
Listener.setConnectErrorCallback(....) and don’t use the global error callback.

Details
Versions: Nakama {2.8.1}, {Windows}

@lugehorsam
Copy link
Contributor

This should be resolved by the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants