Sorry for the delay, but I canceled my subscription to this group on
nov 2 and therefore I saw your answer just now.
Anyway, the problem is still present. I haven't solved this issue, as
I preferred going on by implementing other functionalities and hoping
that in a successive GAE release it would be solved.
Here is an image URL that I am trying to fetch:
http://almaoffice0.appspot.com/GetImage?id=32001

Here is the source code of the servlet serving the image. Maybe the
error is there... You're the expert.

[code]
@Override
        public void doGet(HttpServletRequest request, HttpServletResponse
response) throws IOException{
                long imageId = 1;
                OutputStream os = response.getOutputStream();
                try{
                        try {
                                imageId = 
Long.parseLong(request.getParameter("id"));
                        } catch (Exception e){
                                return ;
                        }
                        FilesController c = new FilesController();
                        FileData imgData = c.selectById(imageId);
                        response.setContentType(imgData.contentType);
                        byte[] d = imgData.data.getBytes();
                        os.write(d);
                } catch (Exception e){
                        e.printStackTrace(out);
                } finally {
                        os.close();
                }
        }
[/code]

Thank you,
Cristian Babula.

On Nov 3, 12:03 am, "Jason (Google)" <[email protected]> wrote:
> Just to clarify:
>
> Your URL Fetch request for a given image on your server fails after 6
> seconds even though you've configured the deadline to be the maximum 10
> seconds, and you've tried serving the image from another App Engine servlet
> as well and saw the same issue. Is this right?
>
> Can you send me the image URL that you are trying to fetch?
>
> - Jason
>
> On Fri, Oct 30, 2009 at 2:11 AM, nicanor.babula 
> <[email protected]>wrote:
>
>
>
> > First of all, thanks for your answer.
> > I think further information is needed for you to understand my
> > problem. The server which encounters this problem, practically takes
> > as input some template pseudo-code, that contains references to images
> > (like html <img src="img url"/>), and generates some output based on
> > that. In order to generate the output data, it has to download (via
> > java.net.HTTPConnection) the images from the various urls and
> > transform them. The problem is that already the first attempt to
> > download an image times out under 10 secs, although I did
> > setConnectTimeout(10000).
>
> > On Oct 29, 9:51 pm, "Jason (Google)" <[email protected]> wrote:
> > > Is the server on which your JPEG is hosted especially slow?
>
> > The server where the JPEGs are hosted is not slow. In fact, as I
> > mentioned above, I tried serving the images with an google app engine
> > servlet, but the error still remains. I supposed than, that the issue
> > is not on the server that serves the images.
>
> > > Note that the
> > > default timeout limit for URL Fetch requests is 5 seconds. You can
> > increase
> > > this up to 10 by passing 10000 (ms) into setConnectTimeout().
> > Already did that, but the browser's ends after 6 seconds.
>
> > > Also keep in mind that your image will have to be smaller than 1 MB if
> > > you're planning to use it with the Images service or store it in the
> > > datastore.
>
> > As I already mentioned, that is not a problem, as I tried retrieving
> > the images from an application engine servlet.
> > Besides, I am very aware about the limits specified in the docs.
>
> > > - Jason
>
> > > On Wed, Oct 28, 2009 at 8:37 AM, nicanor.babula <
> > [email protected]>wrote:
>
> > > > Hello everyone,
>
> > > > I have somewhere on the net a servlet that serves jpeg images. In
> > > > order to verify that it works I made a html page with:
> > > > <img src="http://myurl/servlet?id=123"; />
> > > > and the image is displayed well.
>
> > > > Now, I am trying to create an GAE image object from the data arriving
> > > > from that servlet. How can I do?
> > > > So far I tried this code*[1], with a lot of variations, and I keep
> > > > getting timeouts and "The API call urlfetch.Fetch() took too long to
> > > > respond and was cancelled." error message in my application's logs.
>
> > > > Locally, in the development server, it works.
>
> > > > I also tried storing this images in the datastore and serving them
> > > > directly from GAE.
> > > > Example of image url:http://almaoffice0.appspot.com/GetImage?id=24001
>
> > > > Any ideas?
>
> > > > *[1]: the code:
>
> > > >       ImagesService imagesService =
> > > > ImagesServiceFactory.getImagesService();
> > > >        try {
> > > >            URL url = new URL(stringUrl);
> > > >            HttpURLConnection connection = (HttpURLConnection)
> > > > url.openConnection();
> > > >            connection.setRequestMethod("GET");
> > > >            connection.setReadTimeout(0);
> > > >            connection.setRequestProperty("ContentType", "image/
> > > > jpeg");
> > > >            connection.setDoInput(true);
>
> > > >            if(connection.getResponseCode() ==
> > > > HttpURLConnection.HTTP_OK){
> > > >                InputStream in = connection.getInputStream();
> > > >                byte[] imgData = new byte[in.available()];
> > > >                in.read(imgData);
> > > >                Image oldImg = ImagesServiceFactory.makeImage
> > > > (imgData);
> > > >                Transform resize = ImagesServiceFactory.makeResize
> > > > (oldImg.getWidth(), oldImg.getHeight());
> > > >                 // I do an useless transformation, in order to force
> > > > the conversion to jpeg
> > > >                return imagesService.applyTransform(resize, oldImg,
> > > > ImagesService.OutputEncoding.JPEG);
> > > >            } else {
> > > >                throw new Exception("cannot retrieve image @ " +
> > > > stringUrl);
> > > >            }

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to