Unity NetCode connect my WebGL build to my own dedicated server through domain name URL instead of IP address

I am trying to connect my Unity WebGL build to my own dedicated server hosted on AWS through a domain name instead of an IP address.

However, when I fill in a domain name instead of an IP address in the “Address” field of the Unity Transport component it gives me a bunch of errors saying the network address is invalid.

Am I missing something? I also tried adding https://, ws:// or wss:// in front but none of these options work.

I need this in order to use connect to my dedicated server on a WebGL build because it requires a secure connection when the build is hosted on a domain secured with HTTPS.

I am currently using NetCode for GameObjects version 2.2.0 and Unity 6000.0.25f.

Unfortunately, Unity Transport currently only works with Ipv4 and Ipv6 addresses in that field. You’ll want to look into some sort of Relay service to handle connecting clients together rather than using direct connection.

Ok, thanks for confirming. I’ll look for other solutions then :slight_smile:

If the domain name, as usual, maps to a static IP then just use the static IP.
You can even resolve a hostname to IP at runtime in C# if you want to retain the ability to point the hostname to another IP in the future.

If you intend to use dynamic DNS for a public / published game, I’d advice against that because it will likely create connectivity issues for players and may even be against the TOS of dynamic DNS services.

I’m happy to report that Netcode for GameObjects versions 2.4.0 or higher now supports fully qualified host names as a connect address on the client side!

1 Like

I tested it with my vps and it seems to not work
my vps is like that xxx.yyyyy.zzz is that normal ?
I get a “Invalid network endpoint: myvpsdns“
and a “Target server network address (myvpsdns) is Invalid!”

note: I have the newest versions

Do you mind reporting a bug from the unity editor to further investigate this issue?

Note that there were some issues with hostname validation that could have resulted in these errors. This was fixed recently but has yet to be released. If you’re willing to test unreleased software you can point your package to the develop-2.0.0 branch of NGO’s repository to try this fix. Otherwise it should be part of the next release of NGO.

I’d also recommend updating the Unity Transport package to its latest version (2.5.3) as it also contains a hostname-related fix when using the WSS protocol. It doesn’t look like that’s the issue here, but wouldn’t hurt to update just to be sure.

Thanks for the reply to both of you, I will try it whenever I rework on this game and if the patch is done by then.