Search Unity

Third Party I'm having trouble using AWS server with Mirror

Discussion in 'Multiplayer' started by Jiggs_758, Sep 29, 2022.

  1. Jiggs_758

    Jiggs_758

    Joined:
    Sep 19, 2022
    Posts:
    3
    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
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,445
    have you opened AWS firewalls?
     
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    whatever the SocketException says is usually correct.
    sounds like a firewall issue.
     
  4. Jiggs_758

    Jiggs_758

    Joined:
    Sep 19, 2022
    Posts:
    3
    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?
     
    Last edited: Oct 1, 2022
  5. JamesFrowenDev

    JamesFrowenDev

    Joined:
    Oct 10, 2015
    Posts:
    20
    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
     
  6. Jiggs_758

    Jiggs_758

    Joined:
    Sep 19, 2022
    Posts:
    3
    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?
     
    Last edited: Oct 1, 2022
  7. MaxMoon_

    MaxMoon_

    Joined:
    Sep 29, 2022
    Posts:
    2
    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.
     
  8. MaxMoon_

    MaxMoon_

    Joined:
    Sep 29, 2022
    Posts:
    2
    aaaaHA. Unity changed how headless builds work in 2021. In shrines BuildScript.cs, replace

    Code (CSharp):
    1. buildPlayerOptions.options = BuildOptions.CompressWithLz4HC | BuildOptions.EnableHeadlessMode;
    with

    Code (CSharp):
    1. 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.
     
    hieudinhinwave likes this.
  9. hieudinhinwave

    hieudinhinwave

    Joined:
    Feb 11, 2022
    Posts:
    6
    Thank you, I'm finding for this change :D
     
  10. nipundavid

    nipundavid

    Joined:
    Feb 6, 2013
    Posts:
    10
    I am using EC2 instance instead of Lightsail as I wanted to setup reverse proxy for webGL -https://mirror-networking.gitbook.io/docs/manual/transports/websockets-transport/reverse-proxy
    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.
     
  11. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Please join our discord and ask in #help, I believe MrGadget wrote the part with the reverse proxy