Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Communication between Android and Windows build - Unity Transport v1.3.0

Discussion in 'Unity Transport' started by bryandalo, May 12, 2023.

  1. bryandalo

    bryandalo

    Joined:
    Sep 20, 2013
    Posts:
    18
    I want to use Unity Transport for my two applications as way of communication. The Android(client) will just send data when button clicked to my Windows(server) application. While testing in two editor everything seems to work really well. But when I build to Android device, the connection is not working. Please tell me if this is possible to achieve using Unity Transport version 1.3.0.

    For reference I am just using this exact sample for testing.

    Any input would be really a great help!
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    429
    That sample will have the client connect to the localhost address (127.0.0.1). This will only work if the client runs on the same machine as the server. If you want a remote client (like an Android phone) to connect to your server, you will need to connect to your server's IP address. So instead of the client connecting to
    NetworkEndpoint.LoopbackIpv4.WithPort(7777)
    , you'd connect to
    NetworkEndpoint.Parse("SERVER_IP", 7777)
    . If both your PC and phone are on the same LAN (e.g. same wireless network), you can use this article to find your PC's IP address. It usually looks something like 192.168.X.Y.

    If doing that the connection still fails, I'd give a look at this question in the FAQ. Oftentimes this will be caused by the firewall on your PC blocking the incoming connection requests.
     
    V_SeanPark likes this.
  3. bryandalo

    bryandalo

    Joined:
    Sep 20, 2013
    Posts:
    18
    Thank you, I will try this thing and back on this thread once fix is confirmed.
     
  4. bryandalo

    bryandalo

    Joined:
    Sep 20, 2013
    Posts:
    18
    It is working now! But I have to build the application first because for some reason I can't connect to the server if it is in editor.
     
  5. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    429
    You could use conditional compilation to use different code between your Android builds and the editor. Or you could have the IP address be entered manually from your game UI. That's something you'll probably need to do at some point anyway since different players will want to connect to a different IP address (and even on your own network the IP address might change once its DHCP lease expires).