I’m having major issues trying to get an IWebSocket connection to work in my C++ game (Engine version 5.7.4, source built).
I’m initialising the connection like so:
// URL equals ws://localhost:8080/ws?token=***&characterId=***
// WebSocketProtocol is "ws"
WebSocket = FWebSocketsModule::Get().CreateWebSocket(URL, WebSocketProtocol);
WebSocket->OnConnected().AddUObject(this, &UWolServerAuthSubsystem::HandleWebSocketConnected);
WebSocket->OnConnectionError().AddUObject(this, &UWolServerAuthSubsystem::HandleWebSocketConnectionError);
WebSocket->OnMessage().AddUObject(this, &UWolServerAuthSubsystem::HandleWebSocketMessage);
WebSocket->OnClosed().AddUObject(this, &UWolServerAuthSubsystem::HandleWebSocketClosed);
WebSocket->Connect();
However, I am met with only the text Connection failed in the error handler bound to the connection.
I don’t see any requests hitting my server for the WebSocket endpoint.
If I put in a log that prints the URL, and copy that value, I can connect perfectly fine to my server via Postman.
I’ve also tried using SSL and connecting via wss:// (works via Postman, same failure via Unreal Engine).
At this point I’m a bit stumped. Really hoping someone else has run into this and it’s a simple fix.