I'm having trouble using AWS server with Mirror

I’m trying to set up a dedicated AWS server for multiplayer Unity game with mirror, following
tutorial by Shrine.

But I’m having trouble.

I downloaded the unity file that Shrine provided,
and did everything same as he did (except for unity version. I opened the file in Unity version 2021.3.9)
which works fine when I connect to the host and local client on my computer.

But when I try to conntect it using AWS server, it fails to connect
with error message on console :
Client Recv: failed to connect to ip=~~~~ port=~~ reason=System.Net.Sockets.SocketException (0x8004005): Connection failed because the target computer rejected the connection

Also when I follow Shrine with terminal,
when I type
./Server.x86_64 to the VS code terminal,

I got
"
[UnityMemory] Configuration Parameters - Can be set up in boot.config
“memorysetup-bucket-allocator-granularity=16”
“memorysetup-bucket-allocator-bucket-count=8”
“memorysetup-bucket-allocator-block-size=4194304”
“memorysetup-bucket-allocator-block-count=1”
“memorysetup-main-allocator-block-size=16777216”
“memorysetup-thread-allocator-block-size=16777216”
“memorysetup-gfx-main-allocator-block-size=16777216”
“memorysetup-gfx-thread-allocator-block-size=16777216”
“memorysetup-cache-allocator-block-size=4194304”
“memorysetup-typetree-allocator-block-size=2097152”
“memorysetup-profiler-bucket-allocator-granularity=16”
“memorysetup-profiler-bucket-allocator-bucket-count=8”
“memorysetup-profiler-bucket-allocator-block-size=4194304”
“memorysetup-profiler-bucket-allocator-block-count=1”
“memorysetup-profiler-allocator-block-size=16777216”
“memorysetup-profiler-editor-allocator-block-size=1048576”
“memorysetup-temp-allocator-size-main=4194304”
“memorysetup-job-temp-allocator-block-size=2097152”
“memorysetup-job-temp-allocator-block-size-background=1048576”
“memorysetup-job-temp-allocator-reduction-small-platforms=262144”
“memorysetup-temp-allocator-size-background-worker=32768”
“memorysetup-temp-allocator-size-job-worker=262144”
“memorysetup-temp-allocator-size-preload-manager=262144”
“memorysetup-temp-allocator-size-nav-mesh-worker=65536”
“memorysetup-temp-allocator-size-audio-worker=65536”
“memorysetup-temp-allocator-size-cloud-worker=32768”
“memorysetup-temp-allocator-size-gfx=262144”
"
which I think something is going wrong (it’s different from Shrine’s tutorial).


I’m working on:
Window 11
Unity version 2021.3.9 - Windows, Mac, Linux Vuild Support (mono), Linux dedicated server module
AWS lightsail server

I tried changing the host number (in both Unity Network manager and AWS),
and also tried to add the port number to my Window firewall, which didn’t work.

Is there any way to use AWS dedicated server with Unity 2021.3.9 and Mirror?
I have been working on this for two weeks, and I can’t figure what’s the problem
Please, Any help would be appreciated

have you opened AWS firewalls?

whatever the SocketException says is usually correct.
sounds like a firewall issue.

I added firewall rule to AWS; ‘TCP protocol and port 7777’; just like Shrine did on 6:17 tutorial, if that’s what you meant. Or is there anything else I have to do to open AWS firewalls?

The Default transport has changed since that tutorial. It is now KCPTransport which uses UDP instead of TCP. If you are using that you will need to open UDP ports instead

Thank you for your kind reply.
I deleted the whole Mirror file in the tutorial unity file and reimported Mirror, and I added KCP component to the Networkmanager. I also added custom UDP 7777 port on AWS, and rebuild the Linux Server and did eveything again.

But the Terminal still gives me
[UnityMemory] Configuration Parameters - Can be set up in boot.config ~~~~.
And when I run it on Unity, it fails to connect and the console gives me
“Client Transport Error: Timeout: KCP: Connection timed out after not receiving any message for 10000ms. Disconnecting… This is fine.”
this. Should I also change the AWS firewall rule SSH and HTTP connection from TCP to KCP too? Or is there anything else I have to do?

I’m having the same issue when I try to build in unity 2021.3.11. In particular, when I run the server build in AWS I get that same output. Before it would actually kick off the server. When I run an old server build I made with the old unity version it still works as expected.

I originally set up the project in 2020.3.18 with the shrine tutorial and everything worked fine. Upon upgrading, server builds no longer work and output the same stuff Jiggs mentioned. I can run a local server in unity just fine.

aaaaHA. Unity changed how headless builds work in 2021. In shrines BuildScript.cs, replace

buildPlayerOptions.options = BuildOptions.CompressWithLz4HC | BuildOptions.EnableHeadlessMode;

with

buildPlayerOptions.subtarget = (int)(StandaloneBuildSubtarget.Server);

This will at least fix the issue with the headless AWS side of things, not sure what you have going on in unity with errors.

1 Like

Thank you, I’m finding for this change :smile:

I am using EC2 instance instead of Lightsail as I wanted to setup reverse proxy for webGL -Reverse Proxy | Mirror
as my client is WebGL app.

anyone who has done that please share the workflow. I am not able to connect with the server running on Linux ec2.

Please join our discord and ask in #help, I believe MrGadget wrote the part with the reverse proxy