Javascript client error

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

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

Javascript client error

Postby steve13627 » 17 Jul 2017, 04:49

I am trying to use javascript client to connect my local smartfox server, but it failure, the server version is:2.9.0. Is the older version smartfox not supporting js client? The error as below:
Attachments
QQ图片20170717125727.png
(23.93 KiB) Not downloaded yet
QQ图片20170717125715.png
(31.04 KiB) Not downloaded yet
QQ图片20170717125651.png
(24.19 KiB) Not downloaded yet
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error |waitting online

Postby steve13627 » 17 Jul 2017, 05:16

Is there anybody has the same error?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Javascript client error

Postby Lapo » 17 Jul 2017, 07:28

Websocket is configured on port 8888 but it seems your client is attempting to connect on 8080.
You should use 8888.

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

Re: Javascript client error

Postby steve13627 » 17 Jul 2017, 08:25

I just tried with port 8888, got the error "[SFS2X DEBUG]
Can't establish socket connection"
, please let me know if any information necessary
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Javascript client error

Postby Lapo » 17 Jul 2017, 08:39

1) Make sure you're using the right Javascript API.
In our download page we have two API for Javascript, one supports binary protocol (version 1.7.5) and requires the latest SFS2X 2.13
The other is version 1.7.1 and is compatible with all previous SFS2X versions.
http://www.smartfoxserver.com/download#p=client

Make sure to use version 1.7.1

2) Firewalls
Make sure there's no firewall blocking communication on port 8888.
If client and server are running on two separate machines, check them both as you might have a firewall blocking both sides

Let us know
Lapo

--

gotoAndPlay()

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

Re: Javascript client error

Postby steve13627 » 17 Jul 2017, 09:27

Thanks for your reminder, i've replace the JAVAscript API with version "1.7.1". Now the error is become as "WebSocket connection to 'ws://127.0.0.1:8888/websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED".The code is like this:

Code: Select all


var sfsConfig = {};
sfsConfig.host = "127.0.0.1";
sfsConfig.port = 8888;
sfsConfig.zone = "Generic";
sfsConfig.debug = false;

var sfs;

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

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

   // Disable interface
   enableInterface(false);

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

   
   // Create SmartFox client instance
   sfs = new SFS2X.SmartFox(sfsConfig);
    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);
 

   // Attempt connection
   sfs.connect();
}
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error

Postby steve13627 » 17 Jul 2017, 09:37

BTW, the server and client are in the my local machine , meanwhile I've close the firewall in my local.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Javascript client error

Postby Bax » 17 Jul 2017, 13:15

In your first screenshot you have WSS protocol active.
You should disable it for local testing.
Paolo Bax
The SmartFoxServer Team
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error

Postby steve13627 » 18 Jul 2017, 01:54

Thanks for your help, now I am able to connect SFS server, but login failure. Is there any help document for JS Client API-1.7.1?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Javascript client error

Postby Bax » 18 Jul 2017, 07:45

This is the legacy JavaScript API doc: http://docs2x.smartfoxserver.com/api-do ... ient-json/
Can you better explain what error you get?
Paolo Bax
The SmartFoxServer Team
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error

Postby steve13627 » 18 Jul 2017, 08:28

I deeply appreciate your help.It's my fault, i was follow the example which is using version 1.7.5, but include 1.7.1 version client api in the project.That's why I am asking for the document, it's really useful for us .
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Javascript client error

Postby Bax » 18 Jul 2017, 08:32

We strongly recommend that you move to SmartFoxServer 2X v2.13 and the new JavaScript API.
Is there a specific reason why you are still using the old version?
Paolo Bax
The SmartFoxServer Team
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error

Postby steve13627 » 18 Jul 2017, 09:20

Some of legacy game are still running in older version and we are going to upgrade the server version in 1-2 months. :D
steve13627
Posts: 50
Joined: 06 Dec 2016, 06:27

Re: Javascript client error

Postby steve13627 » 19 Jul 2017, 06:59

If I upgraded the server which is prior to v2.9.0, I have to reinstall the server. Is the only way to do it?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Javascript client error

Postby Bax » 19 Jul 2017, 07:20

steve13627 wrote:If I upgraded the server which is prior to v2.9.0, I have to reinstall the server. Is the only way to do it?

Yes. Then you can move your Extension to the new installation.
As it regards the server and Zone/s configuration, we recommend to rebuild it using the AdminTool, as some issues may arise if you just move the xml files from the old version to the new one.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Edithgal and 109 guests