Search Unity

Third Party MIRROR: Connect Android client to PC server?

Discussion in 'Multiplayer' started by tanmayband, May 17, 2019.

  1. tanmayband

    tanmayband

    Joined:
    Nov 20, 2018
    Posts:
    5
    Using the Mirror NetworkManager alongwith the NetworkManagerHUD, I made two scenes: one for server, one for client. I tested connecting the client to the server on the same machine (by building out the client scene to Windows) and it works.

    Then.I built out the client scene to Android, and started up the server one on laptop, both devices being connected to the same home wifi. I entered the relevant IP and port on the client phone, and when I hit LAN Client on the phone, it can't connect to the laptop server, and times out and gives

    Client Recv: failed to connect to ip=192.168.x.xx port=xxxx
    reason=System.Net.Sockets.SocketException (...) Connection timed out at 
    System.Net.Sockets.TcpClient.Connect.....


    I tried setting the relevant ports to 'allow' in the firewall, to no avail. How can I go about achieving this?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're referring to the software firewall on the laptop, correct? And the server build isn't itself blocked right?
     
  3. tanmayband

    tanmayband

    Joined:
    Nov 20, 2018
    Posts:
    5
    Yeah, I meant the default Windows firewall. And I haven't built the server one, I just run it from the editor. How do I know if it's blocked or not? Something in the firewall screenshot I uploaded?
     

    Attached Files:

  4. tanmayband

    tanmayband

    Joined:
    Nov 20, 2018
    Posts:
    5
    I got it, my server (windows laptop) firewall was blocking the connection. Even though I had put in an "Allow" rule in Inbound rules, there's apparently Unity editor's own "Block" rule, that blocks any type of connection over TCP and UDP. Had to disable those rules, and it finally worked.

    Later, when I built out the server scene, windows popped up the "Firewall is blocking some features" dialog, I simply clicked Allow and it worked.
     
    diegoop and Joe-Censored like this.
  5. Llama_w_2Ls

    Llama_w_2Ls

    Joined:
    May 16, 2020
    Posts:
    7
    Is this answering the mobile connection problem, because I'm very confused. I can connect to my mobile device from my computer server if the mobile device is the host, but when my computer is the host, i cant connect by my mobile device. Same problem happens between my mobile devices. I cant connect to either despite one being the host and one connecting to their ip. Is the reply above able to solve my issue? Thanks
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    These issues are usually firewall related, either software firewall on the device, or something external in the network path. But i'm confused by your post. You say when your computer is the host, it can't connect to your mobile device, but if your computer is the host it must be your mobile device which attempts to connect to the computer, not the other way around.
     
  7. NKBDL

    NKBDL

    Joined:
    Oct 10, 2017
    Posts:
    1
    Hello there, apparently that's the issue I think I need to sort out. Can you share how you set your firewall on Windows? That d' help very much. Thank you!
     
  8. mughalprince36

    mughalprince36

    Joined:
    Dec 11, 2015
    Posts:
    2
    I have setup an Amazon EC2 server and successfully connected desktop clients to server But My android Build / Client can not Connect to the server. Did you had this kind of issue? Any clues on what's wrong with my Android Build.
     
  9. paulobot_

    paulobot_

    Joined:
    Mar 8, 2020
    Posts:
    2
    this was the issue i had as well! thank you, now i can test running the server on the editor and having the client on mobile.