I donât understand, it seems like your client opens a lot of connections at once, which are all discarded as well, except for one, which seem to work just fine.
The new connections are already being opened even after the previous connections havenât even disconnected yet.
Perhaps check your client-side code to maker certain connections arenât being opened incorrectly, which seems to be the case here.
Iâve added a new blueprint that will make it easier to re-listen to a socket connection.
The blueprint will automatically check if the socket connection is valid and connected, and if so, it will stop all other blueprints (like the Connect blueprint) from ticking the socket connection, and then it will start ticking the socket connection itself.
This blueprint should basically be called whenever the level changes (I call it from my PlayerControllerâs BeginPlay for example, which might not be the best place, but in my game there will always only be one PlayerController so yeah).
The update also fixed a bug where Connect blueprints would sometimes stop prematurely and then return false, even though the connection is successful several ticks later.
Usually this is caused by calling Connect twice on the same socket connection, so it shouldnât happen if you did everything correctly, but still, Iâve added code to deal with it anyway.
The update has been sent to Epic, so now weâll just have to wait.
Edit: The update is now live, the new blueprint is called âRe-listenâ.
But I think I am having the same issue as SalihBalkan now.
On localhost the connection is always successful.
But when I tried to launch client on different machine (on the same network over wifi and also on friendâs pc), connect node returned false right after â[DEBUG] Client has connectedâ message. Some time later my server told me that the client was disconnected because the handshake took too long.
Oddly, it connected successfully on the third try (each time I reopened the client and tried to connect):
Oh and by the way, I planted a lot of breakpoints in .ue4.classes.sockets.SocketServerClientHandler#receivedData to watch the handshake process and it seems that remote client did not send any data (when it failed to handshake).
Weird. My guess would be port forwarding problems, I had weird problems as well until I uploaded and ran the server on a digital ocean droplet, then everything worked fine for me.
The updated socket connection plugin should give warnings now if anything went wrong on the client side, do you see any warnings in the UE4 output logs?
No I donât thing so, it seems like there just arenât any warnings.
Does Connect return true?
By the way, what platform and what UE4 version are you experiencing this with? I was thinking, maybe it doesnât flush well on certain platforms, that could also cause this.
Da mn, Iâm really starting to run out of ideas. Maybe, somehow, the server doesnât recognize the handshake. What happens if you send 10 kilobytes of data (or more)?
There were no handshake at all. I set breakpoints in SocketServerClientHandler#receivedData on handshake stages and they fired only when connection was successful (from the same machine and rarely from remote one).
I should dig into the internal UE4 socket code to see what is going on exactly. It seems like the client side just assumes the connection has failed for no good reason.
I do wonder if this also happens when connecting to other servers, or when other clients connect to the server.
What happens when you make a websocket client (disable TLS) connect to your server? Does it handshake?
It seems so, the problem most likely lies in the client code.
You could test out the client by connecting to a HTTP server, the server will probably disconnect you immediately because the header sent will be
, but it should connect, and the Connect blueprint should return true. If that doesnât happen, there is probably something wrong with the client socket code.