You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Tim Tisdall <ti...@gmail.com> on 2012/06/08 15:47:38 UTC
result from _bulk_docs update being truncated
I'm having a strange intermittent problem where the result returned
from a POST to _bulk_docs is being truncated. I know it's being
truncated because the truncation makes the result invalid JSON and my
script throws an exception because it can't decode it. However, I
can't replicate it consistently and it seems rather random. I'm using
code nearly identical to CouchSimple on the wiki at
http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
.
Right now it's consistently truncating after 65734 characters, but I
saw this occurring in another script at around 2^15 bytes. I suspect
there's something awry with PHP's fsockopen, but I'm hoping someone
here has seen this and found a solution or work-around.
-Tim
Re: result from _bulk_docs update being truncated
Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 8 June 2012 15:55, Dave Cottlehuber <da...@muse.net.nz> wrote:
> On 8 June 2012 15:47, Tim Tisdall <ti...@gmail.com> wrote:
>> I'm having a strange intermittent problem where the result returned
>> from a POST to _bulk_docs is being truncated. I know it's being
>> truncated because the truncation makes the result invalid JSON and my
>> script throws an exception because it can't decode it. However, I
>> can't replicate it consistently and it seems rather random. I'm using
>> code nearly identical to CouchSimple on the wiki at
>> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
>> .
>>
>> Right now it's consistently truncating after 65734 characters, but I
>> saw this occurring in another script at around 2^15 bytes. I suspect
>> there's something awry with PHP's fsockopen, but I'm hoping someone
>> here has seen this and found a solution or work-around.
>>
>> -Tim
>
> The std method for tracking these down is to insert a proxy or packet sniffer in
> between Couch and the library. Charles Proxy is very nice, feel free to select
> something else.
Sorry, too fast.
"and check to see that all the JSON data actually gets emitted from
the client side".
Good luck!
Re: result from _bulk_docs update being truncated
Posted by Tim Tisdall <ti...@gmail.com>.
Okay... For the moment I'm going to try the following change:
while(!feof($s)) {
//$response .= fgets($s);
$response .= fread($s, 8192);
}
fgets() is intended to fetch results up until the line ending, which
don't think makes a lot of sense when the result (I think) never has
any line endings. fread() simply reads the number of bytes indicated
in a binary-safe way.
-Tim
On Fri, Jun 8, 2012 at 9:55 AM, Dave Cottlehuber <da...@muse.net.nz> wrote:
> On 8 June 2012 15:47, Tim Tisdall <ti...@gmail.com> wrote:
>> I'm having a strange intermittent problem where the result returned
>> from a POST to _bulk_docs is being truncated. I know it's being
>> truncated because the truncation makes the result invalid JSON and my
>> script throws an exception because it can't decode it. However, I
>> can't replicate it consistently and it seems rather random. I'm using
>> code nearly identical to CouchSimple on the wiki at
>> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
>> .
>>
>> Right now it's consistently truncating after 65734 characters, but I
>> saw this occurring in another script at around 2^15 bytes. I suspect
>> there's something awry with PHP's fsockopen, but I'm hoping someone
>> here has seen this and found a solution or work-around.
>>
>> -Tim
>
> The std method for tracking these down is to insert a proxy or packet sniffer in
> between Couch and the library. Charles Proxy is very nice, feel free to select
> something else.
>
> A+
> Dave
Re: result from _bulk_docs update being truncated
Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 8 June 2012 15:47, Tim Tisdall <ti...@gmail.com> wrote:
> I'm having a strange intermittent problem where the result returned
> from a POST to _bulk_docs is being truncated. I know it's being
> truncated because the truncation makes the result invalid JSON and my
> script throws an exception because it can't decode it. However, I
> can't replicate it consistently and it seems rather random. I'm using
> code nearly identical to CouchSimple on the wiki at
> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
> .
>
> Right now it's consistently truncating after 65734 characters, but I
> saw this occurring in another script at around 2^15 bytes. I suspect
> there's something awry with PHP's fsockopen, but I'm hoping someone
> here has seen this and found a solution or work-around.
>
> -Tim
The std method for tracking these down is to insert a proxy or packet sniffer in
between Couch and the library. Charles Proxy is very nice, feel free to select
something else.
A+
Dave