You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gabriel Guardincerri <gg...@gmail.com> on 2009/02/09 18:18:40 UTC

How to increase the max size of a REST response

I have a service that returns a list of images. It seems to work, but when
the images are too big or there are several images I don't get all images,
just some of them.
>From the server side I get this messages

Outbound Message
---------------------------
Encoding: UTF-8
Headers: {}
Messages: Outbound Message (saved to tmp file):
Filename: /tmp/cxf-tmp-231627/cos58319tmp
(message truncated to 102400 bytes)

It seems that the response is truncated to 102400 bytes. So that is the
reason of not getting all the images.

Is there a way to increase that max size of messages? or to set it to
unlimited?

Thanks,

Gabriel

Re: How to increase the max size of a REST response

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Awesome! Thank you very much!!!

On Fri, Feb 13, 2009 at 3:15 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> This is a problem of how you are using the CachedOutputStream in the
> client.
> If you wireshark the actual stream, you'll see that the entire message is
> properly sent back to the client.
>
> Once it crosses 64K, the CachedOutputStream starts using a temp file to
> store
> content.   However, when you call "close()", it deletes the file.   Thus,
> you
> would need to process the contents before calling close().   Also, if you
> call
> "bos.getOut().toString()" when in file mode, you just get the toString of a
> BufferedOutputStream which would be useless.
>
> For your case, just do:
>    private static String getStringFromInputStream(InputStream in)
>        throws Exception {
>        return IOUtils.toString(in);
>    }
>
> Dan
>
>
> On Thu February 12 2009 10:08:12 am Gabriel Guardincerri wrote:
> > Oh, sorry, didn't know the the log was talking about truncating the log.
> > Well, I have a test case that reproduces the problem. It is a simple
> server
> > that only has on method that returns a list of WSImage. Each WSImage has
> > some info of the image, and an byte array that represents the bytes of
> the
> > image.
> > The server will return a list of 3 WSImage. If the byte array of each
> image
> > is of length 1024*70, from the client side we get an empty response. If
> the
> > size of the byte array is 1024 we get all the 3 WSImages with all the
> data.
> >
> > This runs with REST/xml and I tested with version 2.0.9 of CXF. To run
> it,
> > just firs run the Server class, and then the Client class. The client
> will
> > log the response if any or say that the response is empty.
> >
> > I'm attaching the jar with the classes and the source code, since I
> > couldn't find a way to create a Jira.
> >
> > Please let me know if you need something else.
> >
> > Thank you,
> >
> > On Mon, Feb 9, 2009 at 7:30 PM, Daniel Kulp <dk...@apache.org> wrote:
> > > It should be unlimitted already.    What you are seeing is the Logging
> > > interceptor truncating what it logs to the logger to avoid the logger
> > > sucking
> > > everything into memory and taking down the server with OOM type issues.
> > > That
> > > shouldn't be affecting what gets sent back to the client.
> > >
> > > Can you create a test case that shows the problem and attach to a JIRA?
> > > That's the best way to help us reproduce it and get it fixed.
> > >
> > > Thanks!
> > > Dan
> > >
> > > On Mon February 9 2009 12:18:40 pm Gabriel Guardincerri wrote:
> > > > I have a service that returns a list of images. It seems to work, but
> > >
> > > when
> > >
> > > > the images are too big or there are several images I don't get all
> > >
> > > images,
> > >
> > > > just some of them.
> > > > From the server side I get this messages
> > > >
> > > > Outbound Message
> > > > ---------------------------
> > > > Encoding: UTF-8
> > > > Headers: {}
> > > > Messages: Outbound Message (saved to tmp file):
> > > > Filename: /tmp/cxf-tmp-231627/cos58319tmp
> > > > (message truncated to 102400 bytes)
> > > >
> > > > It seems that the response is truncated to 102400 bytes. So that is
> the
> > > > reason of not getting all the images.
> > > >
> > > > Is there a way to increase that max size of messages? or to set it to
> > > > unlimited?
> > > >
> > > > Thanks,
> > > >
> > > > Gabriel
> > >
> > > --
> > > Daniel Kulp
> > > dkulp@apache.org
> > > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: How to increase the max size of a REST response

Posted by Daniel Kulp <dk...@apache.org>.
This is a problem of how you are using the CachedOutputStream in the client.   
If you wireshark the actual stream, you'll see that the entire message is 
properly sent back to the client.

Once it crosses 64K, the CachedOutputStream starts using a temp file to store 
content.   However, when you call "close()", it deletes the file.   Thus, you 
would need to process the contents before calling close().   Also, if you call 
"bos.getOut().toString()" when in file mode, you just get the toString of a 
BufferedOutputStream which would be useless.   

For your case, just do:
    private static String getStringFromInputStream(InputStream in) 
        throws Exception {
        return IOUtils.toString(in);
    }

Dan


On Thu February 12 2009 10:08:12 am Gabriel Guardincerri wrote:
> Oh, sorry, didn't know the the log was talking about truncating the log.
> Well, I have a test case that reproduces the problem. It is a simple server
> that only has on method that returns a list of WSImage. Each WSImage has
> some info of the image, and an byte array that represents the bytes of the
> image.
> The server will return a list of 3 WSImage. If the byte array of each image
> is of length 1024*70, from the client side we get an empty response. If the
> size of the byte array is 1024 we get all the 3 WSImages with all the data.
>
> This runs with REST/xml and I tested with version 2.0.9 of CXF. To run it,
> just firs run the Server class, and then the Client class. The client will
> log the response if any or say that the response is empty.
>
> I'm attaching the jar with the classes and the source code, since I
> couldn't find a way to create a Jira.
>
> Please let me know if you need something else.
>
> Thank you,
>
> On Mon, Feb 9, 2009 at 7:30 PM, Daniel Kulp <dk...@apache.org> wrote:
> > It should be unlimitted already.    What you are seeing is the Logging
> > interceptor truncating what it logs to the logger to avoid the logger
> > sucking
> > everything into memory and taking down the server with OOM type issues.
> > That
> > shouldn't be affecting what gets sent back to the client.
> >
> > Can you create a test case that shows the problem and attach to a JIRA?
> > That's the best way to help us reproduce it and get it fixed.
> >
> > Thanks!
> > Dan
> >
> > On Mon February 9 2009 12:18:40 pm Gabriel Guardincerri wrote:
> > > I have a service that returns a list of images. It seems to work, but
> >
> > when
> >
> > > the images are too big or there are several images I don't get all
> >
> > images,
> >
> > > just some of them.
> > > From the server side I get this messages
> > >
> > > Outbound Message
> > > ---------------------------
> > > Encoding: UTF-8
> > > Headers: {}
> > > Messages: Outbound Message (saved to tmp file):
> > > Filename: /tmp/cxf-tmp-231627/cos58319tmp
> > > (message truncated to 102400 bytes)
> > >
> > > It seems that the response is truncated to 102400 bytes. So that is the
> > > reason of not getting all the images.
> > >
> > > Is there a way to increase that max size of messages? or to set it to
> > > unlimited?
> > >
> > > Thanks,
> > >
> > > Gabriel
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to increase the max size of a REST response

Posted by Gabriel Guardincerri <gg...@gmail.com>.
Oh, sorry, didn't know the the log was talking about truncating the log.
Well, I have a test case that reproduces the problem. It is a simple server
that only has on method that returns a list of WSImage. Each WSImage has
some info of the image, and an byte array that represents the bytes of the
image.
The server will return a list of 3 WSImage. If the byte array of each image
is of length 1024*70, from the client side we get an empty response. If the
size of the byte array is 1024 we get all the 3 WSImages with all the data.

This runs with REST/xml and I tested with version 2.0.9 of CXF. To run it,
just firs run the Server class, and then the Client class. The client will
log the response if any or say that the response is empty.

I'm attaching the jar with the classes and the source code, since I couldn't
find a way to create a Jira.

Please let me know if you need something else.

Thank you,

On Mon, Feb 9, 2009 at 7:30 PM, Daniel Kulp <dk...@apache.org> wrote:

>
>
> It should be unlimitted already.    What you are seeing is the Logging
> interceptor truncating what it logs to the logger to avoid the logger
> sucking
> everything into memory and taking down the server with OOM type issues.
> That
> shouldn't be affecting what gets sent back to the client.
>
> Can you create a test case that shows the problem and attach to a JIRA?
> That's the best way to help us reproduce it and get it fixed.
>
> Thanks!
> Dan
>
>
>
> On Mon February 9 2009 12:18:40 pm Gabriel Guardincerri wrote:
> > I have a service that returns a list of images. It seems to work, but
> when
> > the images are too big or there are several images I don't get all
> images,
> > just some of them.
> > From the server side I get this messages
> >
> > Outbound Message
> > ---------------------------
> > Encoding: UTF-8
> > Headers: {}
> > Messages: Outbound Message (saved to tmp file):
> > Filename: /tmp/cxf-tmp-231627/cos58319tmp
> > (message truncated to 102400 bytes)
> >
> > It seems that the response is truncated to 102400 bytes. So that is the
> > reason of not getting all the images.
> >
> > Is there a way to increase that max size of messages? or to set it to
> > unlimited?
> >
> > Thanks,
> >
> > Gabriel
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: How to increase the max size of a REST response

Posted by Daniel Kulp <dk...@apache.org>.

It should be unlimitted already.    What you are seeing is the Logging 
interceptor truncating what it logs to the logger to avoid the logger sucking 
everything into memory and taking down the server with OOM type issues.   That 
shouldn't be affecting what gets sent back to the client.

Can you create a test case that shows the problem and attach to a JIRA?   
That's the best way to help us reproduce it and get it fixed.

Thanks!
Dan



On Mon February 9 2009 12:18:40 pm Gabriel Guardincerri wrote:
> I have a service that returns a list of images. It seems to work, but when
> the images are too big or there are several images I don't get all images,
> just some of them.
> From the server side I get this messages
>
> Outbound Message
> ---------------------------
> Encoding: UTF-8
> Headers: {}
> Messages: Outbound Message (saved to tmp file):
> Filename: /tmp/cxf-tmp-231627/cos58319tmp
> (message truncated to 102400 bytes)
>
> It seems that the response is truncated to 102400 bytes. So that is the
> reason of not getting all the images.
>
> Is there a way to increase that max size of messages? or to set it to
> unlimited?
>
> Thanks,
>
> Gabriel

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog