html5 Connection failed Is the server running at all

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

Post Reply
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

html5 Connection failed Is the server running at all

Post by wulei »

Hello everyone ! I spent hours in vain in order to find answers to my problem in reading other related post and on google.
I have a problem and need your help plz
I need to connect via a Html5/javascript script to SFS2X and send request to it.

I try to connect to SFS2X via HTML 5 and Javascript but after a while i get an error message "Connection failed: Is the server running at all?"
However the logs show that server answered and created a session during this while :
Room created: { Zone: BasicExamples }, [ Room: The Lobby, Id: 0, Group: default, isGame: false ]

Listening Sockets:
{ 127.0.0.1:9933, (Tcp) }
{ 127.0.0.1:9933, (Udp) }
{ 127.0.0.1:8888, (Tcp) }
{ 127.0.0.1:8888, (Udp) }
{ 127.0.0.1:8888 (WebSocket) }

28 janv. 2014 15:26:45,866 Session created: { Id: 7, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49970 } on Server port: 8888 <---> 49970
28 janv. 2014 15:27:23,337 Session removed: { Id: 7, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49970 }
Here is my code :

Code: Select all

var sfs = null;
function Connect(){	
	sfs = new SmartFox();

	// Add event listeners
	sfs.addEventListener(SFS2X.SFSEvent.CONNECTION, onConnection, this);
	sfs.addEventListener(SFS2X.SFSEvent.CONNECTION_LOST, onConnectionLost, this);

        sfs.connect("127.0.0.1",8888);
}

//------------------------------------
// SFS EVENT HANDLERS
//------------------------------------
function onConnection(event)
{
	if (event.success){
		trace("Connected to SmartFoxServer 2X!", true);
	}
	else	{		
		var error = "Connection failed: " + (event.errorMessage ? event.errorMessage + " (code " + event.errorCode + ")" : "Is the server running at all?");
		showError(error);
	}
}
Thanks for answers and your help

PS i also did the test with Examples and same issue so i think it should probably come from the SFS2X server configuration
am i wrong ?
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: html5 Connection failed Is the server running at all

Post by wulei »

hello again !
I have finally resolved the problem
In the administrator panel, I change this :
"Server Configurator" > "Html5 websockets" > "WebSocket listener address" = "127.0.0.1" (port 8888)
into this
"Server Configurator" > "Html5 websockets" > "WebSocket listener address" = "myPublicIPAdress" (port 8888)
Thanks anyway ^^
Post Reply