HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

carbon_crystal
Posts: 4
Joined: 28 Apr 2017, 07:46

HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby carbon_crystal » 28 Apr 2017, 08:20

Hi. as title said, I'm using JS Client to connect to Smartfoxserver 2X, but it can't success.
I have tried to connect to server by pure Websocket API then successful, with SFS2X client, I get only the info below by all time and nothing else

Code: Select all

[ SFS2X | INFO ] Attempting connection to server
[ SFS2X | INFO ] Sending request 'HandshakeRequest' to server


This is my code and info

Code: Select all

      app.sfs = new SFS2X.SmartFox();
      app.sfs.debug = true;
      app.sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, onConnection, this);
      app.sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, onExtensionResponse, this);
      app.sfs.connect("localhost", 8080, false);
      
      function onConnection(event) {
         if (event.success) {
            console.log("Connected to SmartFoxServer 2X!");
         } else {
            alert("Failed!");
         }
      }
      
      function onExtensionResponse(event) {
         console.log(event);
      }


Server version: Smartfoxserver 2X v2.13
All server configurations is default.
Client API:
- Version: 1.7.0
- Release date: Apr 26th, 2017

thank for help!

----Update----

I have new problem with product server. now I'm need to connect to a server version 2.8.5. And option "Enable WS/WSS" is on but my problem appear again
I tried to use Client API 1.7.1 and it can connect to server but there is no SFSObject in API, the document for SFSObject 's just work with Client API 1.7.0.
What can I do in this case?
Last edited by carbon_crystal on 28 Apr 2017, 09:48, edited 2 times in total.
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby Lapo » 28 Apr 2017, 08:32

Hi did you turn on the "Enable WS/WSS" option from the AdminTool > Server Configurator > Webserver?

Also:
I have tried to connect to server by pure Websocket API then successful, with SFS2X client, I get only the info below by all time and nothing else

What do you mean by "pure Websocket API"?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
carbon_crystal
Posts: 4
Joined: 28 Apr 2017, 07:46

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby carbon_crystal » 28 Apr 2017, 08:46

Thank for your response!
I just do your suggestion and it connected. :D :D
Sorry for "pure Websocket API", I mean I tried to connect without using SFS2X Client API.
Anyway, thanks again!
carbon_crystal
Posts: 4
Joined: 28 Apr 2017, 07:46

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby carbon_crystal » 28 Apr 2017, 09:35

Hi, I have new problem with product server. now I'm need to connect to a server version 2.8.5. And option "Enable WS/WSS" is on but my problem appear again
I tried to use Client API 1.7.1 and it can connect to server but there is no SFSObject in API, the document for SFSObject 's just work with Client API 1.7.0.
What can I do in this case?
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby Lapo » 28 Apr 2017, 10:03

It depends on which Javascript client API you're using.
You can see here: http://smartfoxserver.com/download/sfs2x#p=client
that we have two types of JS API. One with "binary protocol" and one without.

The binary JS API work with SFS2X 2.13 and higher. For any version lower than that (as in your case) you need to download and use the regular API.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
carbon_crystal
Posts: 4
Joined: 28 Apr 2017, 07:46

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby carbon_crystal » 28 Apr 2017, 10:08

Like I said, the regular API doesn't have SFSObject (am I wrong?), so I don't know how to add params for sending a custom command.

Code: Select all

TypeError: SFS2X.SFSObject is not a constructor


do you have an example about sending a command to server with the regular JS API?
Someting like this:

Code: Select all

var params = new SFS2X.SFSObject();
      params.putInt("zi", zoneId);
      params.putUtfString("ro", gameTableId);

      app.sfs.send(new SFS2X.ExtensionRequest("cmd", params));
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby Lapo » 28 Apr 2017, 13:13

Is there a specific reason to keep working with an outdated version such as 2.8? That's really old, lots of bug fixes and improvements have been added since then.

With our last release (2.13) we have improved our Javascript API and support for websockets and we're phasing out our old API. Unless there are specific constraints I'd highly recommend working with the new API.

Let us know.
Lapo

--

gotoAndPlay()

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

Re: HTML Client API can't connect to server - hang at "Sending request 'HandshakeRequest' to server"

Postby Lapo » 28 Apr 2017, 13:16

Anyways, back to your question an example is found in the docs for the old API.
See here:
http://docs2x.smartfoxserver.com/api-do ... quest.html

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 3 guests