ASIHttpRequest send a weired status code of zero. Not reaching the server

对着背影说爱祢 提交于 2019-12-07 07:41:59

问题


I use ASIHTTPRequest framework in my iPhone application to manage the HTTP communication. I followed their examples given in the project home page to send asynchronous requests. There we have to implement two callbacks, one for requestFinish and other for requestFailed.

However, 60% of the time requests sent by the iPhone ends up in the "requestFinish" callback method and gives a valid HTTP status code. But sometimes it goes to "requestFailed" callback and the status code become '0' which is confusing. My investigations revealed that the internet connection is ok, and I am sending the request to the correct URL, however no log messages found in server log. So why does the request gets dropped in the middle so randomly? Has anyone came across with this type of issue. Will be very helpful.

Thanks


回答1:


As well as what phooze suggested, there is logging in ASIHTTPRequestConfig.h that you can enable, that may provide a clue as to what is happening.




回答2:


Are you looking at the status code of the ASIHTTPRequest object? That code is simply an HTTP response code - if you didn't get a response, then that should be zero.

Instead, you want to look at the NSError object that the delegate failure callback gives you.

I would use something like:

NSLog(@"%@",[error localizedErrorDescription]);

To print out to the log what the error is. Of course, "error" is the name of the variable in the method signature - you should double-check that, I think that's what the default is.




回答3:


In [ASHTTPRequest initialize], I changed

[sharedQueue setMaxConcurrentOperationCount:4]

to

[sharedQueue setMaxConcurrentOperationCount:10]

This work for me, but I don't know why.

MORE:

I found this.



来源:https://stackoverflow.com/questions/4263504/asihttprequest-send-a-weired-status-code-of-zero-not-reaching-the-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!