doushou6480 2014-06-15 13:29
浏览 63

来自xcode的php mysql帖子限制在41左右

In my iPad app, I am getting reports that the user can input. Ones he is done with the reports he can send them to the server. I am using HTTP Post for this and I have a php web service that is receiving the data. For each report send, the php give feedback that the information was correctly stored in mysql.

I am facing the issue that the user can only send around 41 reports, after that the php is not responding to the reports send. After waiting some time, around 20-30 minutes, the user is once again able to send reports, until getting to the limit of the 41 reports.

What need to be changed in php.ini or mysql that the user can send all reports without the before mentioned issue.


I am using this code for iOS and sending each report one after the other.

NSMutableData *body = [NSMutableData data];
NSString *data = [NSString stringWithFormat:@"uniqueID=%@&fecha=%@&numID=%@&rep=%@&hosp=%@&folio=%@&diagnostico=%@&tratamiento=%@&dosis=%@&quimio=%@&medico=%@", uniqueID, strFecha, strNumID, info.rep, info.hosp, info.folio, info.diagnostico, info.tratamiento, strDosis, info.quimio, info.medico];
iLoop = iLoop + 1;
NSLog(@"data: %d", iLoop);
[body appendData:[data dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];

NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
  • 写回答

1条回答 默认 最新

  • doutan4831 2014-06-16 06:19
    关注

    One of two problems are possible.

    1. Client-side limitations:

      Generally, you would want to constrain how many concurrent uploads you are performing. NSURLConnection imposes limits itself, and if you initiate too many, you risk having some of the latter ones time out.

      The typical solution to this problem is to (a) create an NSOperationQueue with a maxConcurrentOperationCount of 3 or 4; (b) wrap the upload in an NSOperation. Using AFNetworking makes this process very simple.

      If you're going to do it yourself, you can wrap your delegate-based NSURLConnection in a concurrent NSOperation subclass as Dave Dribin describes (though I might suggest making it cancelable, as outlined here).

      I'd heartily suggest you consider using AFNetworking (which wraps the network requests in operations) and make sure you specify maxConcurrentOperationCount of 3 or 4.

      By the way, I'd make sure you implement connection:didFailWithError:, and update your question with the reported NSError. That will help diagnose what the problem is.

    2. Server-side limitations:

      You describe some manifestations of the problem (notably, having to wait 20-30 minutes), which is not consistent with client-side issues. Is it possible that the server is enforcing some criteria?

      If there really is some server limitation (which I find unlikely), you should go to the author of the server code and identify the precisely limitations/guidelines. Then you can develop the client code accordingly.

    Personally, I'd be more inclined to suspect the first point and it seems like you should do that, anyway. You never want to initiate too many concurrent requests.

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?