Search Unity

Here is a way to fix Profiler error "Unable to forward traffic to device"

Discussion in 'Linux' started by imerso, Jun 24, 2017.

  1. imerso

    imerso

    Joined:
    May 6, 2011
    Posts:
    278
    To help anyone who searches for this problem (which probably happens under Windows as well):
    1. Build and Run your app with both "Development Build" and "Autoconnect Profiler" enabled; I know, it'll stop with the error, but the app should be installed on the device;
    2. When you see the error "Unable to forward traffic to device", check the Editor Console to find the error; it also shows the complete command-line that Unity used when trying to connect. It looks like this:

      Code (csharp):
      1.  
      2. /(some_path)/Sdk/platform-tools/adb -s "ce09160128d8321405" forward "tcp:34999" "localabstract:Unity-com.somename.someproject"
      3.  
    3. Copy the command you see exactly as shown (select it and CTRL+C), and then close Unity;
    4. Open a terminal (on Ubuntu: CTRL+ALT+ T), and paste the same command there (on Ubuntu: CTRL+SHIFT+V). Press ENTER, of course; you should see no errors, which means that adb accepted the command now;
    5. Open Unity again, and wait until it finishes loading;
    6. Now manually run your app on the connected Android (do *not* disconnect the device from the USB cable, just run the app manually while still connected); you should see the Profiler running against your app -- if not, then change the "Active Profiler" (a combobox located at the top of the Profiler window).
    That is a bit annoying but you only need to do that once per session. After connected, you can rebuild as many times as you wish without having to repeat the process.

    Good luck!
     
  2. fssdev

    fssdev

    Joined:
    Jan 16, 2017
    Posts:
    50
    If I do this, adb gives me this:
    error: cannot bind listener: cannot bind to 127.0.0.1:34999: An attempt was made to access a socket in a way forbidden by its access permissions. (10013)
     
  3. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Ask nicely with sudo (or from an Administrator shell in Windows).
     
  4. fssdev

    fssdev

    Joined:
    Jan 16, 2017
    Posts:
    50
    I'm in an admin command prompt
     
  5. imerso

    imerso

    Joined:
    May 6, 2011
    Posts:
    278
    Did you close Unity before issuing the command? You are expected to paste the command then close Unity before pressing ENTER in the terminal.
     
  6. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Yeah, it's either the port already in use (by Unity and any running Android debugger) - or the firewall blocking it.
     
  7. fssdev

    fssdev

    Joined:
    Jan 16, 2017
    Posts:
    50
    Thanks guys, that did the trick. Closed all my apps.
     
  8. davtam

    davtam

    Joined:
    Nov 27, 2016
    Posts:
    3
    THANK YOU SOO MUCH FOR THIS!!!! :D

    If it was not for people such as yourself posting their solutions to issues, Unity would not be as great and accessible.

    All the best.
     
    imerso likes this.
  9. imerso

    imerso

    Joined:
    May 6, 2011
    Posts:
    278
    Hey davtam, very thank you for the kind comment!
     
  10. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Thanks for the info about closing unity before connecting via shell. It didn't work otherwise!
     
  11. homeslice

    homeslice

    Joined:
    Aug 2, 2013
    Posts:
    12
    An Oldie but a Goodie -Saved my Life - THANKS!
     
  12. homeslice

    homeslice

    Joined:
    Aug 2, 2013
    Posts:
    12
    Is there some permanent solution to this?