Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Meta Quest client times out but works as host

Discussion in 'Netcode for GameObjects' started by MINDCONSOLE, Mar 19, 2024.

  1. MINDCONSOLE

    MINDCONSOLE

    Joined:
    Jun 14, 2016
    Posts:
    5
    Hi,

    I have a very basic NetCode setup with one synced transform just for testing.

    When I start the host from the Quest I can connect to it from the editor and everything works as expected.

    But when the editor is the host, or another Quest, I cannot connect from the Quest and the connection times out.

    So basically the Quest is able to be a host but not a client.
    (Editor-editor works fine).

    Am I missing something?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Possibly. ;)
    Without any code that's nearly impossible for us to tell though.

    How do you test editor-editor? I suppose Multiplayer Playmode (if not: use that).

    Check that your wifi router isn't the culprit. Easiest is to add Relay to your test, if connection works then its your local network setup. You probably have to add port forwarding. But weird that it would only work one-way, that's not typical for a port forwarding issue.

    Perhaps the Quest also has networking security issues or app requirements (like Android manifest) to satisfy.
     
  3. MINDCONSOLE

    MINDCONSOLE

    Joined:
    Jun 14, 2016
    Posts:
    5
    This is the setup for conenction, as simple as it can be. I am calling these methods with 2 buttons, the ip parameter is the ip of the hosting device.

    Code (CSharp):
    1.     public void StartHost()
    2.     {
    3.         var unityTransport = NetworkManager.Singleton.GetComponent<UnityTransport>();
    4.         unityTransport.SetConnectionData("0.0.0.0", PORT);
    5.         NetworkManager.Singleton.StartHost();
    6.     }
    7.    
    8.     public void Connect(string ip)
    9.     {
    10.         var unityTransport = NetworkManager.Singleton.GetComponent<UnityTransport>();
    11.         unityTransport.SetConnectionData(ip, PORT);
    12.         NetworkManager.Singleton.StartClient();
    13.     }

    ParrelSync
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Don't forget to set the serverlistenaddress (third parameter). This should be 0.0.0.0 to allow all incoming connections.
    If the Quest uses IPv6 (not familiar) then maybe try IPv6 addresses.

    Last thing: shutdown is important. When you open a port you need to make sure it also gets closed. I tend to assume that Netcode does that no matter how the app shuts down but with today's devices where the app isn't actually quitting but pushed to the background you may still have an open port. Rebooting all devices should clear all possibly open ports. Or increment the port number for every new test to be sure.

    And add a script that responds to NetworkManager events like OnStartServer/Client and connection/transport events to be able to log those.
     
  5. MINDCONSOLE

    MINDCONSOLE

    Joined:
    Jun 14, 2016
    Posts:
    5
    Unfortunately, I have already tried this and it did not solve my issue :/
     
  6. MINDCONSOLE

    MINDCONSOLE

    Joined:
    Jun 14, 2016
    Posts:
    5
    I tried with Relay and it is working, not sure what is the problem with a simple local connection.