Hello.
I am using Unreals WebSockets module to connect to a websocket server.
I have a lot of code around this, but essentially my websocket is declared like so:
TSharedPtr<IWebSocket> WebSocket;
And then is initialized like so
WebSocket = FWebSocketsModule::Get().CreateWebSocket(serverUrl);
if (WebSocket.IsValid()) {
WebSocket->OnMessage().AddLambda([this](const FString& data)
{
//callback code
});
WebSocket->OnRawMessage().AddLambda([this](const void* Data, SIZE_T Size, SIZE_T)
{
//callback code
});
WebSocket->OnConnected().AddLambda([this]()
{
//callback code
});
WebSocket->OnClosed().AddLambda([this](uint32 StatusCode, const FString& Reason, bool bWasClean)
{
//callback code
});
WebSocket->OnConnectionError().AddLambda([this](const FString& reason)
{
//callback code
});
}
else {
//report error
}
And then there is a call to connect like so:
WebSocket->Connect();
So the problem is, I want to have 2 different websocket connections. I am able to connect to my first without any problem, but when trying to connect the second, I get this big error:
[2024.01.23-21.03.33:333][319]LogOutputDevice: Error: === Handled ensure: ===
[2024.01.23-21.03.33:336][319]LogOutputDevice: Error:
[2024.01.23-21.03.33:339][319]LogOutputDevice: Error: Ensure condition failed: CurrentNum == InitialNum [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 256]
[2024.01.23-21.03.33:343][319]LogOutputDevice: Error: Array has changed during ranged-for iteration!
[2024.01.23-21.03.33:346][319]LogOutputDevice: Error: Stack:
[2024.01.23-21.03.33:350][319]LogOutputDevice: Error: [Callstack] 0x00007ff9e899b366 UnrealEditor-WebSockets.dll!UnknownFunction []
[2024.01.23-21.03.33:353][319]LogOutputDevice: Error: [Callstack] 0x00007ff9e899a4bd UnrealEditor-WebSockets.dll!UnknownFunction []
[2024.01.23-21.03.33:356][319]LogOutputDevice: Error: [Callstack] 0x00007ffa16566870 UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:361][319]LogOutputDevice: Error: [Callstack] 0x00007ffa1658541b UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:364][319]LogOutputDevice: Error: [Callstack] 0x00007ffa16551778 UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:367][319]LogOutputDevice: Error: [Callstack] 0x00007ffa1656508e UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:370][319]LogOutputDevice: Error: [Callstack] 0x00007ffa16566870 UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:374][319]LogOutputDevice: Error: [Callstack] 0x00007ffa1658541b UnrealEditor-Core.dll!UnknownFunction []
[2024.01.23-21.03.33:377][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d432cea9 UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:380][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d434d28c UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:383][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d434d37a UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:387][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d4350854 UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:390][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d4366984 UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:394][319]LogOutputDevice: Error: [Callstack] 0x00007ff6d4369d7a UnrealEditor.exe!UnknownFunction []
[2024.01.23-21.03.33:397][319]LogOutputDevice: Error: [Callstack] 0x00007ffb1da27344 KERNEL32.DLL!UnknownFunction []
[2024.01.23-21.03.33:400][319]LogOutputDevice: Error: [Callstack] 0x00007ffb1db626b1 ntdll.dll!UnknownFunction []
And then it still connects successfully after this error.
Fortunately, this isn’t breaking anything, but I am trying to set up some unit tests and despite the connection being successful, my automation test is failing due to this error being present.
Looking in my code, I’m not really doing any changes to arrays while iterating through them. And that call trace seems to be pointing at Unreal engine code, so it’s really difficult to understand what is causing this.
Any help is greatly appreciated.