Game Development Community

HTTPObject Unable to Connect to a Server

by Dave Calabrese · in Technical Issues · 08/15/2008 (9:44 am) · 6 replies

I'm attempting to access a simple .PHP file I tossed up on my server. Here is the code I'm using:

$HTTPThingie = new HTTPObject( HTTPClient );

$HTTPThingie.get("www.gaslightstudios.net:80", "/test.php");

function HTTPClient::onLine( %this, %line )
{
	error("@@@ Ding!");
}

Whenever the game runs the 'get' command, I always receive this message in the console:
Error connecting to www.gaslightstudios.net: No error

I'm not exactly sure what the problem here is. I've got all firewalls turned off. It appears to be finding the server (since if I use another web address that does not exist, I get a DNS Lookup Failed message instead). If I type www.gaslightstudios.net/test.php into a web browser, I receive the correct response of "Hello !". Also, no matter what addresss I enter in for my .get address, I get that same error. This also occurs with the .connect() method.

Anyone got any tips on what might be going wrong here?

- Dave Calabrese
Gaslight Studios

#1
08/15/2008 (2:08 pm)
Further testing shows that this issue does not occur in the latest build of TGB, however it does occur in TGEA. I'm wondering if there is a bug in TGEA causing this to occur? I'm going to move this over to the TGEA Engine Forums as I think I've found where the issue is occuring and need to post that...

-Dave Calabrese
Gaslight Studios
#2
08/17/2008 (8:54 am)
Fix is here

Cheers,
Rene
#3
12/05/2008 (12:55 pm)
I am having the same problem with TGE 1.5 using code from:
http://www.garagegames.com/blogs/27414/15118

my code:

function scoreTest(%name, %score)
{
%server = "$server";
%path = "/uploadScore.php";
%script = "name=" @ %name @ "&score=" @ %score;

%httpObj = new HTTPObject(scoreUploadHTTPObj);
%httpObj.Get(%server, %path, %script);
}

function scoreUploadHTTPObj::onConnectFailed(%this)
{
echo("Connection Failed");
}

function scoreUploadHTTPObj::onConnected(%this) {
echo ("Connected");
}

function scoreUploadHTTPObj::onLine(%this, %line)
{
echo ("Online");
if(getWord(%line, 0) $= "replyData") {
if(getWord(%line, 1) $= "No")
MessageBoxOK("DID NOT UPLOAD SCORE", "Your score has not been uploaded. (Rejected)", "");
else
MessageBoxOK("UPLOADED SCORE", "Your score has been uploaded!", "");
}
}
#4
12/05/2008 (12:56 pm)
I also cannot view the link Rene posted and I replaced my actual server addr with the dummy variable $server in the above post
#5
12/05/2008 (1:03 pm)
Sorry 1 more thing, the error I get is that the onLine function is never triggered....
#6
12/05/2008 (5:52 pm)
Make sure that whatever data your server sends to torque has a newline ( \n ) on the end of it. That is how the object will know to call onLine and pass whatever data it received to it.