Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Wonky llHTTPRequest issue

Marcus Moreau
frand
Join date: 25 Dec 2004
Posts: 602
09-22-2006 20:46
Ok, I have a script that performs an llHTTPRequest call against a php/mysql system to see if an entry is there. If not (body returns blank), it does another call inside the http event to put the entry in. Only this time it fails and returns a status of 503 (instead of 200). If I have it paste out the URL, and then I copy that into a web browser, it works fine. So I know it's not URL construction. It is really strange though. Anyone ever seen this before?

I could put sample code, but it is complex and messy so I'll just throw this out there first.

Thanks,
MM
_____________________
Marcus Moreau

Disenfranchised island owner...

"This statement is false."
User #121869 or something close
Tuach Noh
Ignorant Knowlessman
Join date: 2 Aug 2006
Posts: 79
09-22-2006 22:19
Error 503 is "Service Unavailable." It's fairly serious, and typically indicates an overload condition on the server. (5xx error codes are intended to indicate "this error is not your fault" to the client, but since you are the server side developer, you probably can't depend on that.)

First, check your site's access log (not the error log). If the request appears there, it is on that end. If there is no entry for the request at all, then it never made it that far.

If it's present, it's a server-side issue, so the first place to check would be your site's error log. If there's nothing there, start adding error_log() calls to your PHP to see if and how far it executes.

Linden uses caching proxies for outbound llHTTPRequests, so if the request is not in your site's access log, there could also be something wonky about your URL that is causing them to puke on you. You might get useful information in the response body if this is the case.
Marcus Moreau
frand
Join date: 25 Dec 2004
Posts: 602
09-23-2006 07:25
Thanks for the tips. I knew what 503 was and the weird thing is all the other requests, no matter how frequent, are all 200. I will attempt to look at some logs and see what is up.

One thing I think I noticed (have not verified) is that if I hard-coded the URL it worked fine. It is only when I concatenate strings. But again, if I have it llOwnerSay the URL and then copy/paste into a web browser, it works fine. It's just like that attempt from within the http event fails for some reason.

I am not sure how to parse the body of the error, as it is bigger than a string/memory. I'll have to see what I can do there.

Cheers,
MM
_____________________
Marcus Moreau

Disenfranchised island owner...

"This statement is false."
User #121869 or something close
Marcus Moreau
frand
Join date: 25 Dec 2004
Posts: 602
09-23-2006 07:31
Addendum, no entries in the web error log, which is actually what I suspected. It sounds like some sort of malformed URL, but it's not. heh I just don't get it. I can try and paste some code without giving the actual URLs - so I may try that later.

Any other suggestions are welcome as well.

MM
_____________________
Marcus Moreau

Disenfranchised island owner...

"This statement is false."
User #121869 or something close
Marcus Moreau
frand
Join date: 25 Dec 2004
Posts: 602
09-24-2006 16:34
Can anyone tell me why this constructed URL would return 503 via llHTTPRequest() and work fine when the result is pasted in a web browser?

CODE

string var1 = llList2String(input, 0);
string objectVar = llGetObjectDesc();
string var2 = llList2String(input, 1);
string objectKey = (string)llGetKey();
string tempURL = "http:///domain.com/code.php?var1=" + var1 + "&var2=" + var2 + "&objectVar=" + objectVar + "&objectKey=" + objectKey;
requestid = llHTTPRequest(tempURL, [HTTP_METHOD, "GET"], "");


Cheers,
MM
_____________________
Marcus Moreau

Disenfranchised island owner...

"This statement is false."
User #121869 or something close
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
09-24-2006 17:01
From: Marcus Moreau
Can anyone tell me why this constructed URL would return 503 via llHTTPRequest() and work fine when the result is pasted in a web browser?

CODE

string var1 = llList2String(input, 0);
string objectVar = llGetObjectDesc();
string var2 = llList2String(input, 1);
string objectKey = (string)llGetKey();
string tempURL = "http:///domain.com/code.php?var1=" + var1 + "&var2=" + var2 + "&objectVar=" + objectVar + "&objectKey=" + objectKey;
requestid = llHTTPRequest(tempURL, [HTTP_METHOD, "GET"], "");


Cheers,
MM
It's the three slashes after http:

Also, use llEscapeURL for your variables, ie:

CODE
string var1 = llEscapeURL(llList2String(input, 0));
string objectVar = llEscapeURL(llGetObjectDesc());
string var2 = llEscapeURL(llList2String(input, 1));
string objectKey = llEscapeURL((string)llGetKey());
string tempURL = "http://domain.com/code.php?var1=" + var1 + "&var2=" + var2 + "&objectVar=" + objectVar + "&objectKey=" + objectKey;
requestid = llHTTPRequest(tempURL, [HTTP_METHOD, "GET"], "");
Your browser is trimming off the extra slash to be user freindly.
_____________________
Marcus Moreau
frand
Join date: 25 Dec 2004
Posts: 602
09-24-2006 17:31
From: Jillian Callahan
It's the three slashes after http:

Also, use llEscapeURL for your variables, ie:

CODE
string var1 = llEscapeURL(llList2String(input, 0));
string objectVar = llEscapeURL(llGetObjectDesc());
string var2 = llEscapeURL(llList2String(input, 1));
string objectKey = llEscapeURL((string)llGetKey());
string tempURL = "http://domain.com/code.php?var1=" + var1 + "&var2=" + var2 + "&objectVar=" + objectVar + "&objectKey=" + objectKey;
requestid = llHTTPRequest(tempURL, [HTTP_METHOD, "GET"], "");
Your browser is trimming off the extra slash to be user freindly.


Ok, yeah, I'm a friggin moron! Thanks Jillian!

MM (Mega Moron heh)
_____________________
Marcus Moreau

Disenfranchised island owner...

"This statement is false."
User #121869 or something close
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
09-24-2006 17:42
From: Marcus Moreau
Ok, yeah, I'm a friggin moron! Thanks Jillian!

MM (Mega Moron heh)
You aren't and you're welcome! =^.^=
_____________________