2
votes

I'm using ASIFormDataRequest to send multipart POST data to a server running nginx + php-fpm.

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:sessionKey forKey:@"session"];
[request setPostValue:secret forKey:@"secret"];
[request setPostValue:@"test" forKey:@"description"];
[request setFile:filePath forKey:@"image"]; 
[request setTimeOutSeconds:120];
[request setDelegate:self];
[request startAsynchronous];

However, once in a while (occurs very randomly, hard to reproduce) an empty request reaches server, I'm using the same file for all tests. ASIHTTPRequest peforms requestFinished, like everything's ok.

No server-side errors generated, I checked logs.

Has anyone had this problem before?

1
Updated your ASIHTTPRequest to the latest? Tried manually loading the file then sending the NSData to the server? - Andrew Pouliot

1 Answers

7
votes

I had this problem too earlier today. It has something to do with nginx behaviour on how to reuse a connection. A simple fix is to just add the following to your request procedure:

[request setShouldAttemptPersistentConnection:NO];

This option also has been set to NO by default in the newest build of ASIHTTPRequest. Read more about it at Github:

Stop using persisted connections on POST/PUT