How to connect to local web server

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

You can’t connect to a webserver using the Network class. You need to use the WWW class.

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

This has nothing to do with the OP’s request, don’t post if you don’t know what it’s about.

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

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.

Anyone who ever visits this post, know that the WWW class is now obsolete. Use the UnityWebRequest service instead.

2 Likes