Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Testing HTTP Host connection?

Author
Message
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th May 2013 02:03
So... in Windows 7 under AppGameKit 10811

If I try to connect to my server with the WRONG credentials or if the server is OFF my program freezes when I call
SendHTTPRequest()
I would have thought that SetHTTPHost would return 0 if login fails, but it always returns 1.

So... how do you handle failed log in or downed server issues?

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2013 04:55
Well, this is a outstanding issue about actual return values for the HTTP commands.

I was just discovering today that I need to update the way I check. My internet connection has been slow and my 'waiting' indicator goes too long. It should time out.

But, as for your point, I don't know what the secure w/user&password is actually expecting on the server side. This might be something that TGC could give us more information on.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th May 2013 06:57 Edited at: 4th May 2013 07:12
So I've worked a way around it in Windows, but the behavior on Android is appalling.

Here's my code that ensures connection in Windows:



So this works perfectly in Windows. If the server is OFF or the login credentials are wrong I get the proper error message.
My PHP script that accepts the data echos a 1 on success, 0 on failure, and a 401 error page on failure to login.
So if the response isn't 1 then I know it didn't go through.

Very nice in Windows.

If I load it up on AppGameKit player in Android or if I pack it up into an APK it fails to log in every time (AGK 10811 -- Android 2.3 or Android 4.2).
Also I've noticed some really horrible edit box behavior (it doesn't show the pre-populated text, doesn't show my typing...Android 2.3 --- works fine in 4.2).

So there's an example of how to test the connection, unfortunately it only works in Windows.



Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th May 2013 10:31
GetHTTPResponseReady have 3 return values, don't see
in the last example but see you use a timeout.

Returns 1 if the request previously sent with SendHTTPRequestASync has completed.Returns 0 if the request is still in progress, or -1 if the request failed.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th May 2013 17:25
GetHTTPResponseReady=1 is part of my wait/timeout loop

It appears that it immediately returns 1 in the above example because technically it received a response (either page not exist 404 or unauthorized access 401). Give it a try or show me code that works

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th May 2013 17:55
you can also make your own authorization and answer with
HTTP/1.0 200 OK
and give your parameters with it.

where from comes the 404 or unauthorized access?
from webserver itself? maybe you can change the config.
if you not get the http header in agk its useless for you.
(Paul make a feature request for the HTTP response status.)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2013 17:58
Naphier, are you testing on your home network? By that I mean are you running Apache/PHP/MySQL on your PC and using that as your host?

And are you using an actual IP address (192.168.1.?) or the 0.0.0.0 you displayed?

I have had no difficulties with the basic http commands (v1076 for a while and a few tries with same code in v10811). I tested both with home server (192.168.1.xxx) and with my live site (www.triassicgames.com).

Don't expect to get the 401 or 404 codes back from the GetHTTPResponse command. They appear in html headers seen only by browsers. The AppGameKit setup does not pass through any of that to us.

The return of -1 is new to v10811.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th May 2013 18:10
Yeah I use my actual IP address and credentials. It is on a home network but I have opened it up to outside access. I can open a browser on both of my android devices and access the site via login.
If the server is on I get a response immediately and the above program shows it in a message box. It is a 401 unauthorized access error page.
If the server is off I also get a 1 returned from GetHTTPResponseReady.

Are you accessing pages that are only accessible by login? I can access via browser on the devices without a problem, so it appears that httphost is failing on android.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2013 19:32 Edited at: 4th May 2013 19:32
Quote: "Are you accessing pages that are only accessible by login?"

No, I haven't tried that yet.

This sounds like it might be something the AppGameKit coders need to look at.

EDIT: What, if anything, shows up in the access log on your PC?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th May 2013 06:03
I'm not able to check the access logs until Monday.
Would you mind putting up password protection on your http documents root and giving the above code a shot in Windows and then Android for me if you have a chance?

I'll check the logs first thing Monday.
Thanks!

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th May 2013 17:23
I had a chance to check out the log today and no special surpises in there.
I've replaced my IP with a fake one.
Windows access relays:

We get an initial 401 and then 200 with "sean" logged in.
The data I send to the database via a PHP POST script is recorded properly.

Android relays this:

Just failure, like there was no attempt to send the log in info at all.
I'll post this to the issue report in case it can help Paul.

It's not a big deal if I have to wait for this functionality because I can limit access during development, but after launch... I sure would like my pages ALL protected.

I wonder if having SSL set up makes any difference. I might give that a shot this week.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th May 2013 19:18
I will give your code a test either today or tomorrow (Monday).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2013 18:23
I just ran a test and it was successful.

I set up a test place on one of my sites: www.thetrilobyte.com/agktest

It is username/password protected using htaccess.

The initial test failed when I used the IP address for the domain (and it is a fixed IP address). But when I used the domain name, it worked.

I was able to test in the non-secure mode only, so far. I discovered, much to my embarrassment, that I had somehow managed to not renew the SSL certificate last year. I just started the process to renew it and it might take a bit (they created a new ticket system and seem to be a little slow at the moment).

The following code works and you can test with it:


Upon success, the message (using plain http) is:
Quote: "Connected using 'http'. Received 'sometexttopost' as data."


If you change "u=sometexttopost" to anything other than something starting with "u=", the message returned is:
Quote: "Connected using 'http'. Did not get passed data."


Once I get the SSL certificate back in place, I will test with an https connection and see if it works.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th May 2013 18:38
Works great on windows, but fails on Android 2.3 and 4.2 for me.
Android's where the issue lies. Did you test it there?

I get a message that's a bunch of CSS and finally down at the bottom of the message I see a 401 message.

I'd show you a screenshot, but for some reason the AppGameKit app isn't allowing me to take a screenshot... weird.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2013 18:52
Nope, not tested on Android yet.

And I cannot test on Android 2.3.

I'll let you know the Android results shortly.

But the 401 code means authorization required.

Since it works in Windows, that sounds like something in the Android is not passing what it should.

The CSS is the stuff that sets up the nice error display that my sites use for errors other than 403 (forbidden).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2013 19:25
Okay, I just tested the following (using Message on an Android is not a good idea):


It works fine in Windows.

I tested in Android, Mac and iOS. And it failed on all of them.

I would say this is a bug. Go ahead and post it and use the code listed here as the sample for testing.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th May 2013 19:31
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2013 19:34
Duh! (palm to forehead!)

Right, of course, I know that.

I'll confirm with my test code above.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th May 2013 20:00
Thanks!
Don't poke an eye out with those facepalms!

Login to post a reply

Server time is: 2024-11-24 14:00:16
Your offset time is: 2024-11-24 14:00:16