- Because the infrastructure I'm employing is already threaded, I'm
using -[ASIFormDataRequest startSynchronous] on my image upload. If my
startSynchronous method is running in a secondary thread (which is the
case), will my progressView still be updated properly?
- Any other reasons why this could be happening? I have
'showAccurateProgress' set to YES, just to be sure.
Thanks.
> I'm uploading an image through ASIFormDataRequest. Seems to be working
> fine; only problem is that the progress bar goes from 0 to 100 in
> about 15 milliseconds (my perception; not a measured time), much
> faster than the actual operation.
Is there a chance you are behind a proxy? If so, I would expect the upload part of the request to complete very quickly.
If you are uploading to a local server, again, it may be that the upload is very fast. Depending on what you're doing with the image, it may take some time for the server to return a response after that, which might result in the behaviour you've been seeing.
To debug, turn on DEBUG_REQUEST_STATUS and watch out for the message in the console that will tell you when the upload actually finishes - if this isn't happening before the progress view is updated, there might be a problem somewhere.
> A couple of questions:
>
> - Because the infrastructure I'm employing is already threaded, I'm
> using -[ASIFormDataRequest startSynchronous] on my image upload. If my
> startSynchronous method is running in a secondary thread (which is the
> case), will my progressView still be updated properly?
It should be. Progress delegates always get updated on the main thread, so there's a chance they may lag behind the actual progress slightly if your main thread is busy, but it sounds like you have the opposite problem. :)
Best
Ben
I've tried it in many configurations, most notably, running over 3G.
Pretty much the same behavior every time.
> To debug, turn on DEBUG_REQUEST_STATUS and watch out for the message in the console that will tell you when the upload actually finishes - if this isn't happening before the progress view is updated, there might be a problem somewhere.
I'm seeing two problems routinely:
1) the problem I've already described, the progress bar going too
quickly. According to the debug output, the file really is uploaded
that quickly. Not sure what's going on there, but it seems insanely
fast. Then, there's like a 5-10 second wait where nothing happens,
then the server response arrives. I'm assuming that's just a delay in
our server processing the photo, but it looks pretty odd since the
progress bar is at 100%.
2) I'm pretty frequently (30% of time) getting an error right at the
time the request starts. It's an ASIHTTPRequestErrorDomain error, code
1. Localized description = "A connection failure occurred," underlying
error = "Operation could not be completed. (kCFErrorDomainCFNetwork
error -1005.)"
If you could provide any guidance on either of these issues, I'd
appreciate it.
Thanks.
Greg
>>> I'm uploading an image through ASIFormDataRequest. Seems to be working
>>> fine; only problem is that the progress bar goes from 0 to 100 in
>>> about 15 milliseconds (my perception; not a measured time), much
>>> faster than the actual operation.
>>
>> Is there a chance you are behind a proxy? If so, I would expect the upload part of the request to complete very quickly.
>
> I've tried it in many configurations, most notably, running over 3G.
> Pretty much the same behavior every time.
>
>
>> To debug, turn on DEBUG_REQUEST_STATUS and watch out for the message in the console that will tell you when the upload actually finishes - if this isn't happening before the progress view is updated, there might be a problem somewhere.
>
> I'm seeing two problems routinely:
>
> 1) the problem I've already described, the progress bar going too
> quickly. According to the debug output, the file really is uploaded
> that quickly. Not sure what's going on there, but it seems insanely
> fast.
Is the image under 32KB in size? Upload progress tracking isn't currently possible for the first 32KB, because of limitations in the underlying API.
> Then, there's like a 5-10 second wait where nothing happens,
> then the server response arrives. I'm assuming that's just a delay in
> our server processing the photo, but it looks pretty odd since the
> progress bar is at 100%.
If the server is performing any intensive processing on the image (or is under load), it's possible that it may be taking time to return a response.
It might be worth doing an experiment with NSURLConnection to see if you see different behaviour. If you're targeting iPhone OS 3.0 or above, you can use connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: to track uploads. See if totalBytesWritten reaches totalBytesExpectedToWrite very quickly - if not, it sounds like there must be a problem somewhere.
> 2) I'm pretty frequently (30% of time) getting an error right at the
> time the request starts. It's an ASIHTTPRequestErrorDomain error, code
> 1. Localized description = "A connection failure occurred," underlying
> error = "Operation could not be completed. (kCFErrorDomainCFNetwork
> error -1005.)"
If you turn off persistent connections ([self setShouldAttemptPersistentConnection:NO]), does the problem go away? I recently made a change that seems to have caused some problems on servers that don't send a keep-alive header, it is possible that this is the problem you are seeing.
Thanks
Ben
Unfortunately, I never quite got this working and went with another
approach. (I'm using a spinner now rather than a progress bar...not as
good, but seems adequate.)
I tried to turn off persistent connections, but I still got the same,
occasional errors when trying to upload my image data.
I look forward to using ASIHTTPRequest for future work...
Thanks for your help,
Greg