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.

iOS and MacOS / SetHTTPHost fails on iOS if using protected directory

Author
Message
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 16th Nov 2013 21:04
So I found out today why my app would not connect to my server when running it in an iOS simulator.
Apparently if you use SetHTTPHost with the user and password parameter then it will not work in iOS. Works great in Android and Windows. iOS will fail to connect.
XCode output states the page requested closed prematurely. The output is like this (where the stuff inside <> is the true values you'd use to connect to your server):
<user><password>@<host>/<page> closed prematurely

So yeah, that's not ideal. After shutting of the password protection on my directory (not what I want to do at all) AND changing SetHTTPHost to only use the host and https parameters everything works a-OK.

So... can someone run a simple test case that AppGameKit can use to confirm the bug?
Should be easy, just they need a server with a protected directory and an unprotected directory.

Yay bugs!

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 16th Nov 2013 23:19 Edited at: 16th Nov 2013 23:20
Reported as issue 612:
https://code.google.com/p/agk/issues/detail?id=612

I'm going to email Paul about it too. I'm sure he'll be happy to hear from me again, but since our release is looming I need to do all I can to have this addressed as it will be painful to implement later.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th Nov 2013 00:28
How are you doing the connection? Can you show the code you use to do the connection?

I have had no trouble with using a password protected connection.

Instead of including the user name and password as part of the URL, use them in the SetHTTPHost command and you should have no problems.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Nov 2013 01:38
I am putting them in SetHTTPHost. It is just the xcode log that shows it like that.
Are you sure you have this working in iOS because it does not work at all for me.

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Nov 2013 02:11
Here's my request function



It's really quite straight forward and I'm very perplexed as to how you have it working and it would not work at all on the simulator or on my friend's iPhone until I removed the password protection on my server's directory AND switched over to SetHTTPHost(con.ID, sHOST , iHTTPS_ON)

Maybe it is related to iOS 7? I also really didn't like how Xcode's log window was showing the user name and password combo. Makes me feel like someone could snag the APP file and plug their device in to a computer with XCode and it will show them my protected directory password. But I'm more concerned that it just doesn't work.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th Nov 2013 04:59
Since you are 'double posting' here and the google issue list, look for my response in the google issue list. (Look there and then back here, since I have discovered other things to consider in your posts.)

I have no issues using secure (password protected directory) and non-secure connections in iOS in iOS 6 or iOS 7 (and Android, Mac, and Windows).

But I just looked at your code some more. What happens in HandleHTTPConnection()? What is con.page$ set to? (I can check to see if a basic connection works if you provide the page, user and password.)

Your code is not checking to see if the connection actually works before it does anything else.

Your code is not allowing AppGameKit to really do anything. It never hurts to put Sync() commands in so that AppGameKit actually does the user/device interface things (oh, like HTTP operations) in between requests.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Nov 2013 05:06
Yeah let's just post here. This is going to be confusing.
There's much more code than this. I was simply providing the part that sets the host and requests the page.
There's also the connection handler (HandleHTTPConnection) which creates the connections, refreshes the connections, and checks them for response ready, and gets the response.

Again my code works perfectly in Android and Windows. No problems whatsoever.

As soon as I go to the iOS simulators OR an iPhone 5 it will not connect to my server scripts unless I shut off the password protection AND use the SetHTTPHost(con.ID, sHOST , iHTTPS_ON).

Here's replies to your post on the issue thread (let's just keep it here for now to try to make it a little more simple):
iSECURE_ON is a constant I set in main so that I can toggle between my home server environment and the real server.

"Where is your SetHTTPHost() command in relation to the posted code? That is the command where you send the user name and password."
What do you mean? It's right there.


And wait a tick... you have to set iHTTPS_ON = 1 to use protected directories? I thought it was just if SSL was used. I'm not using SSL and I've left iHTTPS_ON = 0 because I thought I didn't need it. Plus it works perfect like that in Android and Windows.
So maybe that is the issue... testing right now.

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Nov 2013 06:10
Well turning on HTTPS doesn't work in Windows or Android because I'm not using SSL on the server. I'm using shared SSL and I've not been able to get that to work with AppGameKit, nor have I tried too hard.

At any rate... thank you for forcing me to look at my own stuff a little further. It turns out that there was a character in my password that was causing the issue.
I used a random generated pw and it put in a squiggly bracket.
I switch to all alpha-numerics and it works just fine now.

Don't set HTTPS on unless you have SSL, it won't work.
Use only alpha numerics in passwords...
Odd that it is OK on android and windows, but not iOS...

Anyway I need sleep it has been a long day of issues with iOS. Thankfully they are all fixed.
I appreciate your help as always, AL. I hope someone else out there can see this someday and it helps them too.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th Nov 2013 06:18
I am guessing that, since you have closed the google issue, that you have resolved this issue here as well (not everything likes uncommon characters in passwords/username).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Nov 2013 06:20
Yep on to the next issue, but first some sleep!

Login to post a reply

Server time is: 2024-04-18 08:54:33
Your offset time is: 2024-04-18 08:54:33