# How can I trigger GameSession::RegisterServer in dedicated server in PIE mode?

**URL:** <https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 15, 2019, 9:02am UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262 "2019-04-15T09:02:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f76af402](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f76af402](https://forums.unrealengine.com/u/anonymous_user_f76af402)\
**Post date:** [April 15, 2019, 9:02am UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262/1 "2019-04-15T09:02:10Z")

</div>

I am a new user of Unreal, I am struggling to make below logic work in Unreal Editor.

What I want to do is to start a dedicated server and a client in the Editor. Instead of the client connects to the server directly, I want both the client and server to connect to a Matchmaker. And the matchmaker forms a match and send the Arena server details back to client. Then the client connects to the server. We have our own GameSession implementation to do the above logic. It works in below scenario:

From the “Play” drop down menu:

- Enable “Run Dedicated Server”
- Disable “Auto Connect To Server” in the “Advanced Settings"
- Start the game using “Standalone Game”

But the logic does not work when I start the game using “Selected Viewport” from the “Play” drop down menu. After some debugging, I find that it relates to below logic. For some reason the _“GetNetMode()”_ returns _“NM\_Standalone”_ and _“GameSession-\>RegisterServer()”_ is not called.

```
void AGameModeBase::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
	...
	FGameModeEvents::GameModeInitializedEvent.Broadcast(this);
	if (GetNetMode() != NM_Standalone)
	{
		// Attempt to login, returning true means an async login is in flight
		if (!UOnlineEngineInterface::Get()->DoesSessionExist(World, GameSession->SessionName) && 
			!GameSession->ProcessAutoLogin())
		{
			GameSession->RegisterServer();
		}
	}
}

```

Any help is appreciated.

Regards,

---

<div class="post-metadata">

**Author:** ![Philippe23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philippe23](https://forums.unrealengine.com/u/Philippe23)\
**Post date:** [April 29, 2019, 3:50pm UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262/2 "2019-04-29T15:50:54Z")

</div>

I’m seeing the same in 4.21. Auto connect doesn’t seem to factor into it for us.

Looks like the world doesn’t have a net driver set on it yet at this point.

---

<div class="post-metadata">

**Author:** ![JeDeergab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JeDeergab](https://forums.unrealengine.com/u/JeDeergab)\
**Post date:** [June 10, 2019, 1:31pm UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262/3 "2019-06-10T13:31:40Z")

</div>

If you mean custom online subsystem it won’t be that easy of a task. [Source](https://forums.unrealengine.com/development-discussion/c-gameplay-programming/38131-creating-your-own-online-subsystem) look through that forum post for reference I myself referenced it including this page. Also look through these UE wiki pages since it does talk about Online Subsystem and my guess according to the user post on the forum you should be able to create scale down version of your own Online Subsystem.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

I recommend getting into [STEAM’s Online Subsystem](https://docs.unrealengine.com/en-US/Programming/Online/Steam/index.html) and read this [documentation](https://docs.unrealengine.com/en-US/Programming/Online/index.html)

[Creating your own Online SubSystem... - C++ Programming - Unreal Engine Forums](https://forums.unrealengine.com/development-discussion/c-gameplay-programming/38131-creating-your-own-online-subsystem)[Use online subsystem for STEAM](https://docs.unrealengine.com/en-US/Programming/Online/Steam/index.html)

---

<div class="post-metadata">

**Author:** ![Philippe23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philippe23](https://forums.unrealengine.com/u/Philippe23)\
**Post date:** [June 10, 2019, 1:55pm UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262/4 "2019-06-10T13:55:01Z")

</div>

At least for me, we’re just using the built-in OnlineSubsystemNull.

---

<div class="post-metadata">

**Author:** ![ArcainOne](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ArcainOne](https://forums.unrealengine.com/u/ArcainOne)\
**Post date:** [June 10, 2019, 4:22pm UTC](https://forums.unrealengine.com/t/how-can-i-trigger-gamesession-registerserver-in-dedicated-server-in-pie-mode/447262/5 "2019-06-10T16:22:04Z")

</div>

I had this same issue long ago, unfortunately (at least as of 4.21 which I am still using) PIE handles the connection between dedicated server and Client automatically. To test your dedicated server you need to perform a Server Build which requires a source built engine and launch the server. Then, technically to connect to it, you have to either package the game or build the client (both through through the editor) and launch that. You can still attach VS debugger to either of these processes if you need to debug code, the only issues I’ve had are problems that spring up on immediate launch, those are the best (worst) to figure out.

But with the dedicated server built you the Register Server Function is automatically called.

Build guide: [A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Dedicated_Server_Guide_(Windows_%26_Linux))

@JeDeergab has other good links, and thanks for the “create your own online subsystem” been thinking of writing one for a while for testing purposes
