Note that there are some explanatory texts on larger screens.

plurals
  1. PONSURLConnection hangs on recieving not too big amount od data
    primarykey
    data
    text
    <p>I have some code here:</p> <pre><code>(...) NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } </code></pre> <p>and delegate methods:</p> <pre><code>-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"zero"); [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"got %d", [data length]); [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConenction"); [connection release]; [webData release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); [connection release]; [webData release]; } </code></pre> <p>It works pretty good untill more data has to come. Than NSURLConnection "stop working" (with no error, no exception, no quit). I can still use my app. I noticed that problem begin when <code>didReceiveData</code> is being called more than once during the connection. </p> <p>How it looks like step by step from debugger:</p> <pre><code>1. I call theRequest 2. Delegate call didReceiveResponse </code></pre> <p>2010-06-21 18:10:16.708 MyApp[9477:207] zero</p> <pre><code>3. Delegate call didReceiveData </code></pre> <p>2010-06-21 18:10:16.709 MyApp[9477:207] got 6912</p> <p>(gdb) continue</p> <pre><code>4. Delegate call didReceiveData (once again) </code></pre> <p>2010-06-21 18:10:18.027 MyApp[9477:207] got 114067</p> <p>(gdb) continue</p> <pre><code>--&gt; and here is the problem &lt;-- </code></pre> <p>main loop continue with no breakpoint, and <code>connectionDidFinishLoading</code> is not called. Everything is ok when didRecieveData is being called just once.</p> <pre><code>5. Delegate call didFailWithError (after 5 min!) </code></pre> <p>2010-06-21 18:15:18.041 MyApp[9477:207] ERROR with theConenction Connection failed! Error - The operation couldn’t be completed. Connection reset by peer</p> <p>(gdb) continue</p> <p><strong>=============== UPDATE ====================</strong></p> <p>Finally, I have discovered one important thing: True problem is that remote host doesn't finish connection in proper way sometimes (ie. big amount of data), so delegate connectionDidFinishLoading can't be called and after 5 min remote host reset connection.</p> <p>Has anyone the problem too and can help? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload