"Unity" Error Cannot connect to server and cant access localhost:8080...

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

"Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 02 Oct 2022, 13:06

Hello well I am still trying to connect to the server through the unity C# Api. It throw's a error. Idk what I am doing wrong I followed the documentation thoroughly for over 15 hours. I am just trying to be able to connect to the game server and test things out. Which Ip-address is suppose to go in the Host? Sorry bare with me I am trying to figure out why none of my post aren't going through I sent 2-3 so far...Kind of tedious anyways. I am using Unity version 2021.3.11f1 Personal.

I setup the server through the server admin tool panel.
I setup a Zone
I setup a room
I input my Tcp Udp Ip addresses and ports.
I submit it then reloaded then restarted the server I tried connecting and it threw a error cannot connect to server.

I am using Smartfoxserver2x latest version and unity 2021.3.11f1 Personal edition.
I am using the C# Api I have not made any extensions or anything or edited the scenes and or project files. I just simply followed the documentation thoroughly for nearly 15+ hours.

Please if anyone can help me here is a picture below of what it says when I try to connect.
Attachments
spacewar2error.png
(172.31 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Lapo » 02 Oct 2022, 14:29

Hi,
all our examples are configured to connect to the "localhost", i.e. the local machine. If client and server are not on the same physical machine then you'll need to change the address the client uses to the server's public IP address.

Cheers
p.s. =
I am trying to figure out why none of my post aren't going through I sent 2-3 so far

Your very first post on this board goes through a moderation queue, to filter out spam, so it won't appear immediately. From now on your messages will be posted immediately.
Lapo
--
gotoAndPlay()
...addicted to flash games
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 02 Oct 2022, 14:46

Oh so i need a server to test the unity spacewar2 example?
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 02 Oct 2022, 15:30

i changed the ip address the client uses to my ipv4 address under ipconfig in cmd prompt how would one go about setting up the SpaceWar2 demo with a digital ocean droplet server
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Lapo » 03 Oct 2022, 07:57

Artificialized wrote:Oh so i need a server to test the unity spacewar2 example?

It is a multiplayer demo :)
You need SmartFoxServer 2X installed and running on your local machine. That's how all of the Examples work, by connecting to the local server.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Lapo » 03 Oct 2022, 07:58

Artificialized wrote:i changed the ip address the client uses to my ipv4 address under ipconfig in cmd prompt how would one go about setting up the SpaceWar2 demo with a digital ocean droplet server

Were you able to run the demo on your local machine? I would do that before attempting the next step, at least to familiarize with the process.
Lapo

--

gotoAndPlay()

...addicted to flash games
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 03 Oct 2022, 13:43

I could not get pass the login it says CONNECTION LOST: REASON UNKNOWN.

I have the Smartfoxserver2x running i made my Zone SpaceWar2,added a room called Space configured the zone and room and proceeded to unity to run the demo in the editor it throw's a CONNECTION LOST: REASON UNKNOWN.

I also followed the tutorial step's to get it up and running but it wont login.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1.unzip the examples package;
2.under the SmartFoxServer's /SFS2X/extensions folder, create the SpaceWar2 subfolder;
3.copy the /Server/SpaceWar2/Extension-Java/deploy folder's content to the server's /SFS2X/extensions/SpaceWar2 folder just created;
4.copy the SpaceWar2.zone.xml file (containing the Zone configuration) from the /Server/SpaceWar2/Zone folder to your SFS2X installation folder, under /SFS2X/zones;
5.start SmartFoxServer 2X (v2.13 or later is highly recommended);
6.launch the Unity Hub, click on the Open button and navigate to the /Client/SpaceWar2 folder;
**if prompted, select the Unity Editor version to use (v2021.3 or later is recommended);
7.go to the Project panel, click on the /Assets/Scenes folder and double click on the Login scene to open it;
8.click on the Play button to run the example in the Unity Editor, or go to the Build settings panel and build it for your target platform of choice.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I was stumbled on step number 4. seeing i couldn't figure out where to paste the SpaceWar2.one.xml file containting the ZONE configuration from the /Server/SpaceWar2/Zone folder to your SFS2X installation folder, under /SFS2X/zones;.

because there is No (/SFS2X/zones) folder.

9.I built a webgl,and standalone version neither of which worked.

Also i had to reset my router/modem to re-configure the smartfoxserver2x admin tool so it would let me login.So in the future if anyone gets locked out of their smartfoxserver2x admin tool login all they have to do is delete the smartfoxserver2x then shut computer off reset router/modem wait 5 minutes turn computer on then reinstall smartfoxserver2x start the server then proceed to login with the correct credentials in the admin tool panel.
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 03 Oct 2022, 15:01

Lapo wrote:
Artificialized wrote:i changed the ip address the client uses to my ipv4 address under ipconfig in cmd prompt how would one go about setting up the SpaceWar2 demo with a digital ocean droplet server

Were you able to run the demo on your local machine? I would do that before attempting the next step, at least to familiarize with the process.

No i was not able to get the demo scene to run on my local machine and i have portforwarded the ip address and ports.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Bax » 04 Oct 2022, 07:31

If you get a "connection lost" error message, it means that the client connected but didn't complete the login step.
Did you check the Unity console for possible errors? Maybe something is preventing the login step execution.
Paolo Bax
The SmartFoxServer Team
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 04 Oct 2022, 13:27

Bax wrote:If you get a "connection lost" error message, it means that the client connected but didn't complete the login step.
Did you check the Unity console for possible errors? Maybe something is preventing the login step execution.


Well there arent any unity errors in the console log

this is what the console log say's.

GLOBAL MANAGER READY

SFS2X API VERSION 1.7.17

CONNECTION MODE IS WEBSOCKET (BINARY)
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Bax » 04 Oct 2022, 13:34

The API version and the connection mode are printed after the connection is established (see LoginSceneController script, OnConnection method). Then the login is attempted and either a LOGIN or LOGIN_ERROR event should be received by the client.
If no event is received, then something wrong is happening on the server side. Did you check the server-side logs for possible errors?
Paolo Bax
The SmartFoxServer Team
Artificialized
Posts: 8
Joined: 01 Oct 2022, 23:45

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Artificialized » 04 Oct 2022, 14:12

I believe I have the server-side problem fixed as it wasn't in my allowed in my programs for my firewall. Also I disabled custom login is that ok?Now im stuck on the level selector.Deep Space or Saturn so basically im stuck in the lobby selector.I clicked both the deep space and saturn neither of which load the scenes.It throws a a unepected disconnection occured: reason is because i left it idle to see if it would throw any console errors it doesnt.


i checked the debug log and it keeps showing Data read data written Binary size... then Ping pong with SFS (INFO) Message PING PONG
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: "Unity" Error Cannot connect to server and cant access localhost:8080...

Postby Bax » 04 Oct 2022, 16:06

When you select the level, a request is sent to the server-side Extension. If nothing happens, then something wrong is happening on the server side. Again check the server logs.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 25 guests