HTML5 / JS APi fail to connect

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

bribarthelemy
Posts: 5
Joined: 14 Jul 2014, 16:29

HTML5 / JS APi fail to connect

Postby bribarthelemy » 14 Jul 2014, 16:53

Hello,
I 've tried a lot, but I really can't connect to the smartfoxserver 2X with html5 websocket. ( working fine with Flash )

I 've tried with a telnet myip 8888 with success. But not at all with the differents examples in JS/HTML5.

Always the same message : "Connection failed: Is the server running at all? "

Same thing under Chrome /Firefox.

Any Idea?


Thank you so much
Last edited by bribarthelemy on 14 Jul 2014, 20:45, edited 1 time in total.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HTML5 / JS APi fail to connect

Postby rjgtav » 14 Jul 2014, 17:11

Hi there,

Just to make sure, have you enabled the WebSockets protocol on the Server Configurator Module of the Admin Tool?
The html5 examples are hard coded to connect to 127.0.0.1. Have you updated the code so it connects to your server's IP?

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bribarthelemy
Posts: 5
Joined: 14 Jul 2014, 16:29

Re: HTML5 / JS APi fail to connect

Postby bribarthelemy » 14 Jul 2014, 18:38

Thanks for reply!

Yes , I have enabled the websocket
Image

And I have changed the config.xml as you can see in the log console here:

Image


any Idea?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HTML5 / JS APi fail to connect

Postby rjgtav » 14 Jul 2014, 18:56

The config.xml? The AdvancedChat example has the IP hard coded on its main.js file...

Can you also check on the logs if is there any error occuring at the server side?

Thanks
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bribarthelemy
Posts: 5
Joined: 14 Jul 2014, 16:29

Re: HTML5 / JS APi fail to connect

Postby bribarthelemy » 14 Jul 2014, 20:37

Thanks a lot for your help.

However ; I 've changed in main.js ( you can see it on the picture, the ip has been changed )
Image

ANd here is my log :


14 Jul 2014 | 21:47:40,413 | INFO | New I/O worker #2 | bitswarm.sessions.DefaultSessionManager | | Session created: { Id: 2, Type: WEBSOCKET, Logged: No, IP: 109.130.x.x } on Server port: 8888 <---> 53789
14 Jul 2014 | 21:47:40,453 | INFO | New I/O worker #2 | bitswarm.sessions.DefaultSessionManager | | Session removed: { Id: 2, Type: WEBSOCKET, Logged: No, IP: 109.130.x.x:53789 }



another idea?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HTML5 / JS APi fail to connect

Postby rjgtav » 15 Jul 2014, 00:56

Hmm...
On the server-side logs, right before the "SFS2X Ready" ASCII art, where it says "Listening Sockets", does it show the correct 5.XXXX ip with the 8888 port?

Can you check if you didn't made the same mistake as the following post?
viewtopic.php?f=33&t=16833

And please make sure you have no firewall blocking traffic on that port nor and review your router's port forwarding configuration (in case you're behind one)

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bribarthelemy
Posts: 5
Joined: 14 Jul 2014, 16:29

Re: HTML5 / JS APi fail to connect

Postby bribarthelemy » 21 Jul 2014, 15:32

Hello,

Once again, thank you for reply.

As you see on the console, the ip is the internet IP Image

May I ask you something if you have time? COUld you download last release of 2X and html5 exemple ?
And try if all these last one work fine for you...
If you don't have tile. Of course, do not worry :)

In the console log, I have this :
Image

Code: Select all

WebSocket connection to 'ws://5.39.xxx.xxx:8888/' failed: Error during WebSocket handshake: Unexpected response code: 200


Thank you
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HTML5 / JS APi fail to connect

Postby rjgtav » 21 Jul 2014, 20:18

Hi there,

Yesterday I've faced that same error when working on my end.
That error occurs when using the previous API with the most recent version of SFS2X.

You can fix it by downloading the most recent version of the HTML5 Client API from:
http://www.smartfoxserver.com/download/sfs2x#p=client

Cheers
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
bribarthelemy
Posts: 5
Joined: 14 Jul 2014, 16:29

Re: HTML5 / JS APi fail to connect

Postby bribarthelemy » 21 Jul 2014, 20:41

It works soo much better!!!

Thank you :)
User avatar
Lapo
Site Admin
Posts: 21002
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HTML5 / JS APi fail to connect

Postby Lapo » 22 Jul 2014, 09:05

Just to recap. Does the problem go away by using the latest API?

If yes, then it is expected. SFS2X 2.9 requires the usage of the latest HTML5 API.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HTML5 / JS APi fail to connect

Postby rjgtav » 22 Jul 2014, 10:11

Lapo wrote:Just to recap. Does the problem go away by using the latest API?

If yes, then it is expected. SFS2X 2.9 requires the usage of the latest HTML5 API.

Cheers

Ohayo Lapo,

Yeah, the problem is fixed by using the latest API.
The only problem is that the current HTML5 Examples package ships with the previous API version and, therefore, the examples don't work on the latest version of SFS2X by default.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
Lapo
Site Admin
Posts: 21002
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HTML5 / JS APi fail to connect

Postby Lapo » 22 Jul 2014, 10:41

Yes, we're going to update the HTML5 example pack very shortly, with the latest API included.
Sorry for the inconvenience.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Bax
Site Admin
Posts: 4478
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: HTML5 / JS APi fail to connect

Postby Bax » 28 Jul 2014, 09:09

The updated examples pack is now available on the download page: http://www.smartfoxserver.com/download/sfs2x#p=examples
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 0 guests