Search Unity

Setting up profiler port manually

Discussion in 'Editor & General Support' started by denizdurmus, Apr 8, 2020.

  1. denizdurmus

    denizdurmus

    Joined:
    Feb 7, 2020
    Posts:
    6
    Is it possible to set the port for profiler manually? It seems like the port is set randomly between 55000 to 55500 by default.

    I am trying to connect to AWS servers where the instance is running in headless mode. But based on the issues below, I can't do a mapping for port ranges on ECS:

    https://github.com/aws/amazon-ecs-agent/issues/2071

    https://github.com/aws/containers-roadmap/issues/316

    https://github.com/aws/containers-roadmap/issues/194

    Are there any ways to set a profiler port manually, or anyone succeeded dealing with profiler for AWS headless instances?
     
    alexeyzakharov likes this.
  2. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    It is not possible atm - the ports range profiler uses for connection is fixed to the range [55000,55511].
    Alternatively, you might try to use C# API to dump profiler file to some location on instance, then retrieve it from there and load in the Unity Editor.
     
  3. denizdurmus

    denizdurmus

    Joined:
    Feb 7, 2020
    Posts:
    6
    thanks for the details and workaround
     
    alexeyzakharov likes this.
  4. UbiAnthonyB

    UbiAnthonyB

    Joined:
    Jun 28, 2019
    Posts:
    4
    @alexeyzakharov is there a way to retrieve/log the port in the application itself? If I run multiple windows standalone players simultaneously, it's impossible to attach the profiler as far as I've been able to find. It's random whichever instance Unity will find (and often break if you launch another instance)

    This greatly diminishes the usefulness and efficiency of the profiler. I have to make 2 separate builds in 2 different folders of the exact same code and assets to profile.
     
    Last edited: Jul 9, 2020
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,456
    The port should be in the first couple of lines of the player.log

    Just look for "PlayerConnection Initialized" or "Multi-casting"
    Work to be able to specify the port in the attach to player drop-down -> <Enter IP> dialog is underway, likely to land on 2021.1
     
  6. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    That doesn't work in the general case though, unless you have a trivially small project (and don't work with colleagues, who have different computers?)

    1. The port number needs to be known in advance and be guaranteed to be stable otherwise we cannot setup firewall rules
    2. It seems to be the same between all editor instances (experimentally: two different 2019.4.14 editor instances with two different projects created the same port-number), i.e. they clash.

    Which means that you have to keep closing projects and re-opening them to make it work again. But every time you close a project Unity blocks all use of autoconnect profiler - requires you to create a new build (not really documented, but multiple people have discovered and reported this, and it appears in forum threads eg since 2016: https://forum.unity.com/threads/how-to-link-profiler-to-webgl-build.320175/#post-2885399). So you're back to point 1 above.

    Since WebGL builds *cannot be profiled* except using this feature, and this feature is currently broken, this is a set of bugs that I'd expect to see fixed in 2019 LTS, not wait another 1-2 years for an LTS that finally 'isn't broken' for GL builds.
     
    alexeyzakharov likes this.
  7. vqt123

    vqt123

    Joined:
    Apr 16, 2013
    Posts:
    23
    if you turn on the build option to connect to the profiler, Unity will output the port the profiler is using. I was able to use the port number here to create an SSH tunnel locally to port 55001 and then tell unity's profiler to connect to 127.0.0.1 and that is working
     
    alexeyzakharov likes this.
  8. MartijnGG

    MartijnGG

    Joined:
    May 3, 2018
    Posts:
    74
    Has there been any update on this issue? Not being able to specify the port the profiler runs on for standalone builds is making it impossible to profile unity dedicated servers.
     
    Hukha likes this.
  9. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    hey @alexeyzakharov and @MartinTilo,

    sorry to necro this thread but we're in a similar situation to MartijnGG - we'd like to connect the profiler to a remote server (on PlayFab) to try to diagnose a few things. Can we specify a single port for the profiler connection in 2021.3.x yet or is it still a range? Unfortunately every single port on PlayFab has to be opened individually.

    Thanks for any help or advice on how to connect the profiler to a dedicated build hosted remotely.
     
  10. G_Wojo

    G_Wojo

    Unity Technologies

    Joined:
    Feb 8, 2017
    Posts:
    44
    Hi, I have some good news related to this.
    1. There is change of this behaviour. You still cannot decide your ports but we decided to drop random selection of ports in favour of ordered assignment (55000 up). This means if you know you will have one instance of unity running it always will be 55000 if more you can easily just open few next ones.
    2. We are backporting these changes. Currently we landed in 2023.1, 2022.2.0b13, 2021.3.13f and working on version 2020.
    3. There is a lot more nice improvements inside this pack so I want to believe that whole experience with player connection will improve.
    4. There is even more changes that we are working on and plan to backport.
     
  11. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    hi, thanks for following up here about the profiler connection behaviour. The tweaks to the port assignment should be very useful in our situation so thanks for the updates - looking forward to the next release :)
     
    alexeyzakharov and MartinTilo like this.