+ Start a Discussion

java.net.ConnectException: Connection timed out for PageReference.getContent()

I want to get Blob from external image URL but thrown exception.


Apex Debug Log :


System.VisualforceException: java.net.ConnectException: Connection timed out

see following sample code :


public PageReference testPageRefExternalURL() {
      PageReference pr = new PageReference('http://www.google.com/intl/en/images/logos/translate_logo.gif');
      try {
        Blob blobImage = pr.getContent();
      } catch (Exception ex) {
        throw ex;
      return pr;

   I have added 'http://www.google.com'  to 'Remote Site Settings' but still exception is thrown.If I save image in static      resource and get the URL it is work fine.