Why does multiplayer networked game break if a specific computer is the game host?
The problem: Testing a multiplayer game (networked through steam) across two computers (computer 1 and computer 2) each using a different steam account. When computer 1 is the host, computer 2 connects to the lobby fine and when computer 1 initiates the the move to the game play map (via seamless transition) everything loads correctly - UI populates, pawns spawn etc. However, if computer 2 is the host and computer 1 is a connecting client on level transition some parts of the gameplay logic do not execute correctly. It is as though computer 2 simply misses or does not send/receive some of the commands and this varies each time. I've tested this using different 'computer 1's and its always computer 2 hosting that causes the problem. Why would it do this? Is this a network/firewall issue? How would I diagnose this?
It's been a steep learning curve. Most of my problems thus far have been either "I don't understand networking correctly" or " I don't understand how unreal works." However, I got to a stage where, upon moving from the lobby (the same lobby built in the BMN tutorial series) each 'players' UI would be built correctly with the right information and, once all players were connected, each players pawn would spawn.
Recently (Today) I have observed a problem where I the behavior of the project changes depending on which computer is the host. For example, if computer 1 is the host, creates a lobby, computer 2 connects to the lobby, computer 1 initiates map transition via console commands and seamless travel, everything loads in fine. However, if I do it the other way around, (computer 2 host, computer 1 connecting in) then it breaks. Computer 1 seemingly does not execute half of the commands it should. I know that because, after pretty much every function call in gamemode or player controller, I have a call to player controller event (running on the owning client) that prints a string telling me where we are (the string is taken as an argument so I can customise it for each location.) In the working scenario, I'll see all the strings printed that I expect on both machines. In the non-working scenario, the host client will generally print all the strings it should while the connecting client will not. It will generally appear to have gotten through a handful of the commands it should.
I tested with a different computer 1 and the exact same issue occurred. So, something is up when computer 2 is acting as a host. Is this some weird thing in unreal that I'm not getting? Or is it a problem with computer 2? How would I go about diagnosing it? What are the obvious places to look?
Note: I've not included any pictures of my code here as its a mess right now with all the print string commands but I can do so (or simply describe the code if that helps) on request.
try moving the file to your desktop
answered Dec 06 '18 at 10:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here