Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to connect to local web server

Discussion in 'Multiplayer' started by deeDude, Jan 9, 2014.

  1. deeDude

    deeDude

    Joined:
    Jan 8, 2014
    Posts:
    3
    Hello,

    On my unity client app when I try to connect to my local web server (Tomcat 7) who is running on the address 127.0.0.1:8080 I get the error "The connection request to 127.0.0.1:8080 failed[...]". Here is a snippet of my code:

    public class Game: MonoBehaviour {
    public GameObject board;
    public GameObject player;

    void Awake () {

    (...)

    Network.Connect("localhost", 8080); }

    //other methods...
    }


    What is wrong here?

    Cheers
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    You can't connect to a webserver using the Network class. You need to use the WWW class.
     
  3. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,500
    look if the port is correct.
    Try port 25005, 30000, 25000.


    Here i found a video where it connect local. At min 7:00 to 127.0.0 etc

    LINK VIDEO

    hope it can help
     
    Last edited: Jan 10, 2014
  4. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    This has nothing to do with the OP's request, don't post if you don't know what it's about.
     
  5. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,500
    Sory Sr: Thanks for the critic
    I'm learning how to post in this forum.

    I found a more specific video link for a "connect to my local web server"
    link here
    Tell me if this is more correct or not and I will adjust my sensibility accuracy to this forum.
    Kind regards
     
  6. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,500

    Probably i not understood correctly the question. Is difficult to know when "don't know what it's about" I was trying to help and I will limit my comment. Thanks Sr.
     
  7. Llama_w_2Ls

    Llama_w_2Ls

    Joined:
    May 16, 2020
    Posts:
    7
    Anyone who ever visits this post, know that the WWW class is now obsolete. Use the UnityWebRequest service instead.
     
    WrGraban and Joe-Censored like this.