2

I'm experiencing some strange behavior with the ASIHTTPRequest.

I'm trying to connect to a website which prompt a user to give his/her credentials when loading the page.

To implement this with ASIHTTPRequest i've used the following code:

NSURL *URL = [NSURL URLWithString:@"http://fhict.fontys.nl/Pages/Welkom.aspx"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:URL];

[request setUsername:theUsername];
[request setPassword:thePassword];
[request setDelegate:self];

[request startAsynchronous];

I'm sure the credentials given to the request are correct, and when i'm working on WiFi the request succeeds and the app continues..

But when i'm connected to cellular network, the exact same request gives an error: error:Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x2e8ef0 {NSLocalizedDescription=Authentication needed}

I checked, this same error is given when the credentials are incorrect, but i've double checked them and they are correct!

To fix this I've tried:

  • setting the timeout on 2 minutes (overkill I know but just for testing), this resulted the same error
  • enabled and set bandwidth throttling for WWAN (as described on http://allseeing-i.com/ASIHTTPRequest/How-to-use, search for WWAN), but nothing changed
  • setting enabling shouldPresentCredentialsBeforeChallange and adding basichttpheader to the request, but then also WiFi stopped working..

And then a lot of googling later, still no solution.

I'm a little confused because because on WiFi everything works perfectly,

I hope anyone here can point me in the right direction..

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
RuudPuts
  • 66
  • 6
  • I have the same issue except that your workaround doesn't apply for me because the url I'm trying to contact is not working with SSL... – MartinMoizard Sep 21 '11 at 08:26
  • check if the url is redirected, it may be if the url is redirected to many times it fails.. – RuudPuts Sep 26 '11 at 16:49
  • It is not. But I think I figured it out: my mobile provider has a strange encoding and that is breaking the credentials format... It looks like there is nothing I can do. – MartinMoizard Sep 27 '11 at 12:55
  • Can't you use some in-between solution? like a web server where you post the url and the credentials with a HTTP POST and the web server does the rest of the processing? – RuudPuts Sep 30 '11 at 10:16

1 Answers1

0

(Answered in a question edit. Converted to a community wiki answer. See What is the appropriate action when the answer to a question is added to the question itself? )

The OP wrote:

I got a tip and changed the url to https, this solved all issues! (I'm leaving the question for if someone experiences the same in the future..)

Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129