1

I have wifi connected in the devices - so this is ruled out.

The Application i have with the same following code executed is able to upload the file to a java server in the iOS 4.3 simulator but unable to upload in iOS 4.3.3 device. This is kind of strange.

ASIFormDataRequest *request_zip = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:strURL]];
[request_zip setAllowCompressedResponse:YES];
[request_zip setPostValue:@"device" forKey:@"value1"]; //pass device ID here...
//[request_zip addRequestHeader:@"Content-Type" value:@"multipart/form-data"];
[request_zip setTimeOutSeconds:20];
[request_zip setDelegate:self];
[request_zip setDidFailSelector:@selector(uploadFailed:)];
[request_zip setDidFinishSelector:@selector(uploadFinished:)];
[request_zip setFile:path forKey:path];
[request_zip startAsynchronous];
NSLog(@"%@ post length",[NSString stringWithFormat:@"%llu",[request_zip postLength]]);

The code when executed results the following output in the terminal.

Incorrect NSStringEncoding value 0x0000 detected. Assuming NSStringEncodingASCII. Will stop this compatiblity mapping behavior in the near future.

The post length printed in the console =>

0 post length

There is also a another string comes up lastly, i.e the time out message,

Request failed: The request timed out with response data

100% sure that the server is active and responds immediately for the app executed from simulator.

how is it possible to have a program running in simulator properly but not in the device?

Futur
  • 8,444
  • 5
  • 28
  • 34
  • The strURL is perfectly alright. The delegates are executing perfectly when there is a response too. – Futur Jul 08 '11 at 14:34
  • How large are the files you are sending? – ThatGuyInIT Jul 08 '11 at 14:56
  • 30kb compressed and password protected zip file. – Futur Jul 08 '11 at 15:09
  • I finally think that the problem is in the server side java program.. lets see.. im not so sure yet,. – Futur Jul 14 '11 at 06:13
  • 1
    I would agree, you will probably want to use Fiddler, basically setup a remote proxy in Fiddler and then tell your iPad to use the proxy, once you have done this you can see the traffic and it will make debugging much easier http://www.ravelrumba.com/blog/ipad-http-debugging/ – ThatGuyInIT Jul 14 '11 at 15:41

2 Answers2

2

Incorrect NSStringEncoding value 0x0000 detected. Assuming NSStringEncodingASCII. Will stop this compatiblity mapping behavior in the near future.

Means that you have a NSString that is being initalized without a NSStringEncoding value, check your NSString calls.

Empty body in POST in ASIHTTPRequest

Try:

NSURL *requestURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", strURL]];
ASIFormDataRequest *request_zip = [ASIFormDataRequest requestWithURL:requestURL];

The NSLog will fire right after the [request_zip startAsynchronous]; which at that time may just be initialized, you need to move the log request into a delegate method, change this to [request_zip startSynchronous]; and it will fire immediately,.

Then your delegate method will look like this:

 - (void)requestStarted:(ASIHTTPRequest *)request {
   NSLog(@"%@ post length",[NSString stringWithFormat:@"%llu",[request postLength]]);
}
Community
  • 1
  • 1
ThatGuyInIT
  • 2,239
  • 17
  • 20
  • @"file" can be replaced with any string for that matter. actually path is a NSString variable. But at the same time i changed as you suggested :).. still didnt work.. – Futur Jul 08 '11 at 15:08
  • Hi Sean, thanks for the reply sean.. great effort. As you said the content length is getting printed properly. I still unable to upload the file to the host. there is something else i believe. The greatest question here for me is that, the same program executes very well in simulator but not in the device.. plz help me out – Futur Jul 13 '11 at 15:04
1

The problem was with the server end. ASIHTTP lib works properly, when ASI tries to transmit the request with post body to server, the apache didnt respond back properly as one of the server configuration was missing probably. The proprietary web library owners fixed it later and the problem is resolved.

It worked in simulator but not in device, why?

It worked in simulator coz the data is transmitted thru the ethernet not wireless, so the transmission rates were great comparatively.

Web service developers has to plz make sure that the data is received even if it comes in from low speed networks

**

ASI libs returned ASCII encoding error, why?

**

This error is returned by ASI immediately once the request goes time - out. This is the cause, but the real internal problem with ASI for this error has to be found out.

Very interesting results fetched end of the day.

Futur
  • 8,444
  • 5
  • 28
  • 34