Why is the ServerTravel command not recognized for Dedicated Servers?
I'm attempting to create a game using multiple dedicated servers hosted on a single machine.
Since trouble-shooting networking issues tends to involve a lot of background information, I'm going to try to provide a thorough explanation of my setup. Boring details to follow!
I'm attempting to run multiple sessions on a single physical dedicated server.
The Test Project
For testing purposes, I display this UI when a client connects to the centralized server:
Here's the blueprint code for Launch Server and the join buttons on the right:
And here's the blueprint code for the Travel button:
Some notes about the travel code:
For your viewing pleasure, here's my configuration for Maps & Modes and the selected game mode. I do have seamless travel checked on.
It's probably worth noting that I'm not attempting to create/find/join sessions. I was under the impression that using the OpenLevel node to access a dedicated server played a similar role to the session management nodes for listen servers.
Here's the log from my client (with slight modifications and notes):
asked Mar 09 '18 at 03:57 PM in Everything Else
It turns out that my issue was a fundamental misunderstanding of how some of Unreal's built-in classes work. The GameInstance exists on both client and server, but doesn't share information between the two.
"LaunchMapReplicated" is a custom event in the GameInstance class which I'd marked as Run on Server and Reliable. The problem (I believe) is that it wasn't actually running on the server - it was still running on the client. That would explain why the "ServerTravel" command wasn't recognized, since the client wouldn't know how to perform a ServerTravel.
Armed with that assumption, we still have one obstacle to overcome. We need to run the ServerTravel command on the server, but the button click is occurring on the client.
The solution is to run the RPC in a class that actually does successfully replicate. In this case, I just used the PlayerController. I added a client-side RPC which could be invoked directly from the user interface. That calls a server-side RPC which runs the code containing the ServerTravel command.
It's probably not strictly necessary to designate the client-side custom event as a Client RPC (since it's being invoked from the UI, which exists on the client anyway), but I've done it for clarity anyway. The "LaunchMap" function being called by "ServerInvokeTravel" is the same function shown in the original question.
The moral of the story is that it's insufficient to understand what an RPC does - you also have to know where you can use them. I'd recommend checking out this PDF from eXi. The network layout on page 8 was especially helpful. It didn't necessarily answer all of my questions, but it at least got me investigating the possibility that my RPC was in the wrong class!
answered May 24 '18 at 01:16 PM
just a wild guess: does it work if you spell 'servertravel' without any caps (not 'ServerTravel' but 'servertravel')?
answered May 23 '18 at 12:16 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here