Connection Refused

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Connection Refused

Postby Heatkigerr » 13 Mar 2015, 11:10

I'm having some trouble connecting to the server. Specifically I'm using the Advanced Chat example for HTML5. The server is running, and we have successfully connected to the administrator panel from the internet.

However, when connecting through the Advanced Chat index, there is an alert saying Connection Failed: Is the server running at all?. I also checked my browser console when this happened, and the following is what it produced:

WebSocket connection to 'ws://[PUBLIC IP]:8888/websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
(@ SFS2X_API_JS.js:301).

I guess it has something to do with the server's WebSocket setup. I found the documentation a bit lacking at that point, so I'm not really sure what to do with it?
I'd like some explaination. Anyway, here are my server settings for that:

Image

I tried telnet [PUBLIC IP] 8888. It was unsuccessful.

I have portforwarded these in my router to my server's LAN IP.
Image
Should I open up 8888 aswell?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 12:17

The server is configured to listen on 127.0.0.1 (localhost) so it will only allow connections from the machine itself.
If you run the Chat on the same computer it should work fine, like the AdminTool.

If you're attempting to connect from other computers in the network then this setup won't work. Change 127.0.0.1 to 0.0.0.0, which means "all available addresses".
This will solve the issue.

The port forwarding is only necessary if you're trying to connect from outside your network. E.g. the internet.
Also please not that the websocket port is 8888 (or 8443 for wss:// ), which doesn't show up in the port forwarding screenshot.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 12:36

Lapo wrote:The server is configured to listen on 127.0.0.1 (localhost) so it will only allow connections from the machine itself.
If you run the Chat on the same computer it should work fine, like the AdminTool.

If you're attempting to connect from other computers in the network then this setup won't work. Change 127.0.0.1 to 0.0.0.0, which means "all available addresses".
This will solve the issue.

The port forwarding is only necessary if you're trying to connect from outside your network. E.g. the internet.
Also please not that the websocket port is 8888 (or 8443 for wss:// ), which doesn't show up in the port forwarding screenshot.

Hope it helps


Thanks for your quick response :)
I am actually running it on the same computer, and it doesnt work.

This is my Advanced Chat main.js setup:
Image

I tried changing the config.host to 127.0.0.1, which did not work (same error).

I'm not trying to connect from other computers in my network, I'd rather like to allow the entire internet access.

But at the moment it doesnt work from neither the internet nor my computer.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 13:38

Are you running a firewall on your computer? If you use Windows chances it is blocking the TCP port.
Make sure to add a rule for port TCP 8888, so that traffic is allowed.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 14:20

Lapo wrote:Are you running a firewall on your computer? If you use Windows chances it is blocking the TCP port.
Make sure to add a rule for port TCP 8888, so that traffic is allowed.

Thanks


Nope, it is disabled.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 15:38

My colleague made me notice that in your screenshot the "use WSS protocol" switch is turned ON.
That's the problem. :) You have configured websocket to work in SSL mode, therefore it won't work in "regular mode".

Just turn it off, restart the server and you should be up and running.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 16:36

Lapo wrote:My colleague made me notice that in your screenshot the "use WSS protocol" switch is turned ON.
That's the problem. :) You have configured websocket to work in SSL mode, therefore it won't work in "regular mode".

Just turn it off, restart the server and you should be up and running.

Cheers


Changed it, but unfortunately it still doesn't work. :(

Same error.

By the way, thanks for the unbelievable support that one does recieve here! :D

Here is the log that occurs when I start the server. As you can see there are some warnings, maybe they are causing this trouble?

Image

"Filnavnet, mappenavnet eller volumnavnesyntaksen er feil" = "The File name, directory name, or volume label syntax is incorrect." in Norwegian. :?
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 17:35

Here are the results of some telnet commands:

telnet PUBLIC_IP 9933 FAILED
telnet PUBLIC_IP 8080 SUCCESS
telnet PUBLIC_IP 8888 FAILED
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 20:12

Are you sure you're not already running SFS as a service in the background?
That would explain the error. Simply open your browser to localhost:8080/admin/ and see if the AdminTool comes up. If it does you have another copy of the server running.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 20:20

Lapo wrote:Are you sure you're not already running SFS as a service in the background?
That would explain the error. Simply open your browser to localhost:8080/admin/ and see if the AdminTool comes up. If it does you have another copy of the server running.

thanks


Seems like there is another SFS running then. However, it isn't in the task manager process list (unless it's called something else than SmartFoxServer).

How can I avoid this, and could this have caused the failed connection attempts?)

edit: The admin tool does come up, but I cannot log into it. I'm not sure what that means.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 20:36

During the installation process you haven't unchecked the "Install as a service" option, which is the default, if I recall correctly.
You should open the Windows Management Console > Services and look for the SmartFoxServer 2X service. From the you can start/stop the server.

If you have made changes to the config you will need to restart it. Then check the logs to see if there's any error at boot. If the default port 9933 is bound you will be able to run the AdminTool.
Lapo

--

gotoAndPlay()

...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 20:44

Lapo wrote:During the installation process you haven't unchecked the "Install as a service" option, which is the default, if I recall correctly.
You should open the Windows Management Console > Services and look for the SmartFoxServer 2X service. From the you can start/stop the server.

If you have made changes to the config you will need to restart it. Then check the logs to see if there's any error at boot. If the default port 9933 is bound you will be able to run the AdminTool.


Alright, the log errors are gone. However, the bad alias warnings are still there. And the Advanced Chat is still not working.

Does the example have to be placed in the root folder of the SFS directory?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection Refused

Postby Lapo » 13 Mar 2015, 20:47

Don't worry about the bad alias errors. They appear in Windows only, but they are harmless.
Lapo

--

gotoAndPlay()

...addicted to flash games
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 13 Mar 2015, 20:50

Lapo wrote:Don't worry about the bad alias errors. They appear in Windows only, but they are harmless.


Alright :)

telnet [PUBLIC_IP] 8888 should have been working right? Is there anything I have to do to open it?

I have disabled my computer's firewall, and I also tried enabling it and making exceptions for the ports 8080 and 9933 both in and out and for both TCP and UDP.

Could it be something on my router?
Heatkigerr
Posts: 18
Joined: 22 Oct 2014, 22:43

Re: Connection Refused

Postby Heatkigerr » 14 Mar 2015, 12:43

OK! I reinstalled everything and suddenly it works locally :)

I still can't connect from the internet. I have tried different things, and have some questions I would like answered.
A port checker tells me that my router is directing TPC 9933 to my server. However telnet PUBLIC_IP 8888 fails, even though the firewall is disabled. I assume that is where the problem lies

1. Do I need to enable WSS on the server for a public connect through browser?
2. What is my server's Websocket listening address supposed to be?

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 18 guests