Support SmartFox Server version 2.7.0

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Support SmartFox Server version 2.7.0

Postby steve13627 » 02 Feb 2018, 03:51

Hi team

Is it possible to use Js(javaScript) to interact with SmartFox server(2.7.0) ? I am trying to do this, but get the error message as below

Code: Select all

 failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET


Please refer the attachment for the details.


Btw,I am using the JS API version 1.7.1 which is compatible for all previous server version!
Attachments
server-config.png
(11.76 KiB) Not downloaded yet
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 02 Feb 2018, 03:51

Please let me know if you need to any other information
User avatar
Lapo
Site Admin
Posts: 19985
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 02 Feb 2018, 08:49

Hi,
make sure there is nothing blocking the communication, such as a firewall. Try telnetting the websocket port:

Code: Select all

telnet 127.0.0.1 8989

Does it connect?

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 05 Feb 2018, 02:38

Hi Lapo,
As your sugguestion, I ran the cmd in my remote host. Below is the cmd result:

Code: Select all

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.


It seems ok. Am I right?
User avatar
Lapo
Site Admin
Posts: 19985
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 05 Feb 2018, 08:15

Yes,
can you show me the code used for connecting to the server?
Also which browser are you using for testing?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 05 Feb 2018, 08:58

It's a really simple. Please refer the code as below:

Code: Select all

var sfsConfig = {};
sfsConfig.host = "127.0.0.1";
sfsConfig.port = 8989;
sfsConfig.zone = "MultiplayerZone";
sfsConfig.debug = false;
 
var sfs;
 

//------------------------------------
// USER INTERFACE HANDLERS
//------------------------------------



function onConnectBtClick()
{
   document.getElementById("log").innerHTML = "";

   // Disable interface
   enableInterface(false);

   // Log message
   trace("Connecting...");

    // Create SmartFox client instance
    sfs = new SFS2X.SmartFox(sfsConfig);
     
    // Set debugging level
    sfs.logger.level = SFS2X.LogLevel.INFO;
 
    sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, onConnection, this);
    sfs.addEventListener(SFS2X.SFSEvent.CONNECTION_LOST, onConnectionLost, this);
    sfs.addEventListener(SFS2X.SFSEvent.LOGIN, onLogin, this);
    sfs.addEventListener(SFS2X.SFSEvent.LOGIN_ERROR, onLoginError, this);
    sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, onExtensionResponse, this);
 
    sfs.connect();
}


BTW, I am using chrome to testing it.The code is working fine with my local Smartfox server(2.9.0) but not remote server. So I don't think it's client code issue.
User avatar
Lapo
Site Admin
Posts: 19985
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 05 Feb 2018, 14:39

The telnet test shown here is about your local server, which you said already works.
I think you should do the same test on the remote one...

Let us know
Lapo

--

gotoAndPlay()

...addicted to flash games
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 06 Feb 2018, 02:18

Hi Lapo,

The screen shot is from remote server not my local server.
User avatar
Lapo
Site Admin
Posts: 19985
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 06 Feb 2018, 08:30

But the telnet points at 127.0.0.1
If you ran that test on the remote server you were just testing the localhost, not the connection from an external client.

What you need to do is telnetting from your computer at home or office to the remote server, using the remote server's public IP.
In other words on your computer test this:
telnet <server-ip-address> 8989


Let us know
Lapo

--

gotoAndPlay()

...addicted to flash games
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 06 Feb 2018, 11:27

The same result which the remote host ip and port 8989.
User avatar
Lapo
Site Admin
Posts: 19985
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 06 Feb 2018, 15:45

Can you please send me the IP address of your remote server?
If you prefer you can use a private message.

Thanks
Lapo

--

gotoAndPlay()

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

Re: Support SmartFox Server version 2.7.0

Postby Lapo » 07 Feb 2018, 09:45

I've got your message and tested the IP you sent.
The port 8989 is indeed open but the connection get reset without any exchanges. I have no idea why, it seems like the current installation is corrupted. I'd recommend re-installing the server from scratch.

I'd also suggest upgrading to the most recent version (2.13) which still supports to old, legacy websocket protocol.
http://smartfoxserver.com/download/sfs2x#p=installer

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Support SmartFox Server version 2.7.0

Postby steve13627 » 08 Feb 2018, 05:59

Ok. Lapo. Thanks for your suggestion.

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 3 guests