Page 1 of 1

HTML5 / JS APi fail to connect

Posted: 14 Jul 2014, 16:53
by bribarthelemy
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

Re: HTML5 / JS APi fail to connect

Posted: 14 Jul 2014, 17:11
by rjgtav
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

Re: HTML5 / JS APi fail to connect

Posted: 14 Jul 2014, 18:38
by bribarthelemy
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?

Re: HTML5 / JS APi fail to connect

Posted: 14 Jul 2014, 18:56
by rjgtav
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

Re: HTML5 / JS APi fail to connect

Posted: 14 Jul 2014, 20:37
by bribarthelemy
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?

Re: HTML5 / JS APi fail to connect

Posted: 15 Jul 2014, 00:56
by rjgtav
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

Re: HTML5 / JS APi fail to connect

Posted: 21 Jul 2014, 15:32
by bribarthelemy
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

Re: HTML5 / JS APi fail to connect

Posted: 21 Jul 2014, 20:18
by rjgtav
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

Re: HTML5 / JS APi fail to connect

Posted: 21 Jul 2014, 20:41
by bribarthelemy
It works soo much better!!!

Thank you :)

Re: HTML5 / JS APi fail to connect

Posted: 22 Jul 2014, 09:05
by Lapo
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

Re: HTML5 / JS APi fail to connect

Posted: 22 Jul 2014, 10:11
by rjgtav
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.

Re: HTML5 / JS APi fail to connect

Posted: 22 Jul 2014, 10:41
by Lapo
Yes, we're going to update the HTML5 example pack very shortly, with the latest API included.
Sorry for the inconvenience.

Re: HTML5 / JS APi fail to connect

Posted: 28 Jul 2014, 09:09
by Bax
The updated examples pack is now available on the download page: http://www.smartfoxserver.com/download/sfs2x#p=examples