views:

108

answers:

0

I have 30 seconds to load this image, and it seems to be taking longer on Rackspace, but not when I run it locally.

If I go over 30 seconds then the load balancer ends the request, so I get an error.

The code is pretty simple: Image Logo = Image.GetInstance(HttpContext.Current.Server.MapPath(@"~\images\logo.bmp"));

I have it running inside a thread now, so that the rest of the application will work, and when I finish processing the rest of the pdf then there is an exception thrown about the thread being aborted, as I am sending the data to the client and finishing with the HttpResponse.

I am using .NET 3.5 and C#3, if that matters any, as well as ASP.NET.

UPDATE:

I have a logo I am trying to put at the top of the pdf. So, I load data from a database, create a 18 page pdf, and that takes less than 1.5 seconds, but if I try to load the image then it takes over 30 seconds, so I am allowing it to not load the image, just so the rest of the pdf can be generated.

I am creating one image, as I am the only one testing it at the moment, and I am using iTextSharp.text.Image. I forgot to look at the image.

What I am doing is generating the image and saving it as a file, but, it will never get that far as the image loading is taking too long, and so it creates the file, but it is empty.

UPDATE 2:

I made a new file to limit any other factors, and go directly to it, and here is the working part of the program, minus the using and class definition, and after about 30 seconds I get the following result:

Unfortunately there were no suitable nodes available to serve this request.

I was told that this is due to the load-balancer, and a 30 second time-limit, so, after about 30 seconds the load-balancer kills off the request, by sending back this page.

All I get is:

9:54:58 PM : 995 starting to load image ...

private void writeLog(String filedir, String msg)
{
    System.IO.StreamWriter fs = null;
    try
    {
        fs = new System.IO.StreamWriter(filedir, true);
        fs.WriteLine(DateTime.Now.ToLongTimeString() + " : " + DateTime.Now.Millisecond + "\r\n" + msg);
    }
    catch (Exception) { }
    finally
    {
        if (fs != null)
        {
            fs.Close();
        }
    }
}

protected void Page_Load(object sender, EventArgs e)
{
    string myvalue = HttpContext.Current.Server.MapPath(@"~\Logo.bmp");
    string logfiledir = HttpContext.Current.Server.MapPath(@"~\testexception.log");

    writeLog(logfiledir, "starting to load image " + myvalue);
    try
    {
        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(myvalue);
    }
    catch (Exception ex)
    {
        writeLog(logfiledir, ex.ToString());
    }
    writeLog(logfiledir, "finished loading the image");
}

UPDATE 3:

I am loading the image using a web address, and that works, as I changed the image type to be .jpg.

This is a hack, but it works, but I am not certain why it won't work with the local file address. The only thing I can think of is that one server may be generating the pdf and it can't get to the file in a reasonable time where the file actually is located, but, that is a guess.