Client Disconnect after Rejoining Session with Steam
Note that this is only an issue when using the Steam online subsystem.
After successfully connecting to a session, disconnecting, and rejoining that same server, the client will be connected for about 10 seconds before disconnecting, saying it simply lost connection to the server. Other players connected to the server are unaffected, and this only happens after the client has already disconnected from that server.
It happens almost every time, and I've successfully recreated it in a clean project. Additionally, this happens whether or not using the blueprint nodes or manually via C++ and interacting with the session interface.
Steps to reproduce (in blueprint, for simplicity):
If 6 does not happen, it almost always will happen by the third or fourth rejoin. I tried looking into the steam subsystem's source if it was an issue with authenticating via steam, but I couldn't find anything, only that, according to the logs, the server mysteriously decides to close their connection, resulting in the disconnect.
I'd also like to add that we've had this issue for as long as we can remember (at least since 4.7), but assumed it was simply us misusing sessions.
In a simplified test project, these are the log outputs with LogNet and LogOnline set to Verbose Note that in this example, it happened upon the first reconnect of the Client.
If you need the test project, I can provide it if necessary. This is a crucial issue as our game relies heavily upon steam and steam sessions.
Alright I think I've managed to fix this, but I'll post here just to make sure there aren't any unintended side effects.
In the steam socket code, USteamNetConnection overrides the CleanUp() method and calls the relevant function for unregistering and removing the steam P2P connection.
The problem, is that this is called twice; by both NetworkDriver's TickDispatch when it's found to be a straggling connection, but also when that USteamNetConnection is garbage collected. By the time the user rejoins it's about the time that object is garbage collected, and will destroy the same user's steam P2P connection.
So naturally, a simple fix I found was to simply ensure the steam cleanup code was called exactly once: (SteamNetConnection.cpp)
So far in my testing, this has fixed all issues, and still appear to be properly removing connections, but I've not done more extensive/thorough tests. Will this hold up in the long term, would this be a proper fix?
answered Nov 24 '15 at 08:15 AM
Hello Foohy and ooParanoia,
Since Josh has been out and we've gotten some other users reporting the same problem, I went ahead and took a look. You all are right about the problem, and your fix will work, although I've decided to fix it a slightly different way. I changed FSocketSubsystemSteam::UnregisterConnection to be the following:
Like I said, your fix is totally fine as well, but I prefer this one just because it avoids adding some redundant state to the USteamNetConnection object.
If you decide to give my fix a shot and you run into any issues with it, please post again here. This should make it into 4.11.
Thanks again for all your research into this issue!
answered Dec 11 '15 at 04:11 PM
Bart Bressler STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here