AnsweredAssumed Answered

Javascript PrintTask times out after 10 minutes

Question asked by SamuelHenderson on Jun 9, 2015

Hi everyone,

 

I'm trying to print a map made using the ArcGIS JavaScript API.  I'm using version 3.11 of the API with ArcGIS Server 10.1.  Here's my test page (which works with very simple KML layers) http://censusdemo.ssmic.com/printTest.html :

 

<html>
<head>
  <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
  <meta http-equiv="x-ua-compatible" content="IE=9" >
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
  <title>Print Task Test</title>
  <script>
    var dojoConfig = {
   async : true
    };
  </script>
  <link rel="stylesheet" href="http://censusdemo.ssmic.com/arcgis_js_api/library/3.11/3.11/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" type="text/css" href="http://censusdemo.ssmic.com/arcgis_js_api/library/3.11/3.11/esri/css/esri.css">
    <script type="text/javascript" src="http://censusdemo.ssmic.com/arcgis_js_api/library/3.11/3.11/init.js"></script>
  <style>
    html, body, #window, #map {
     height: 100%;
     width: 100%;
     margin: 0;
     padding: 0;
     font-family:arial, helvetica, sans-serif;
    }


   #buttons{
    position: absolute;
    top:  10px;
    right: 18px;
    height: 20px;
    z-index:100;
    box-shadow: none;
    font-size:13px;
   }
  </style>


</head>
<body class="tundra">
  <div id="window">
     <div id="map"  ></div>   


     <div id="buttons">
    <button id="prnt" class="topButton" data-dojo-type="dijit/form/DropDownButton" ><span>Print</span>
     <div  dojoType="dijit/Menu">
      <div  id="png" data-dojo-type="dijit/MenuItem" label="Image(.png)" style='font-size: 13px;'></div>
      <div  id="landscape" data-dojo-type="dijit/MenuItem" label="Landscape(.png)" style='font-size: 13px;'></div>
      <div id="portrait" data-dojo-type="dijit/MenuItem" label="Portrait(.png)" style='font-size: 13px;'></div>
     </div>
    </button>
     </div> 
  </div>     
</body>
<script>
  var map;  
  var PrintTask;
  //var layerResults;


  require ([
   "esri/layers/KMLLayer",
   "dojo/on",
   "dojo/_base/connect",
   "dojo/dom",
   "dojo/query",
   "dojo/parser",
   "esri/map",
    "esri/dijit/Scalebar",
   "esri/arcgis/utils",
   "esri/dijit/Print",
   "esri/tasks/PrintTask",
   "esri/tasks/PrintTemplate", 
   "esri/dijit/Popup",
    "esri/dijit/Attribution",    
   "dojo/dom-construct",
   "dojo/dom-class",
   "dojo/mouse",
   "dijit/form/Button",
   "dijit/Menu",
   "dijit/layout/BorderContainer",
   "dojo/domReady!"
   ],
   function (KMLLayer, on, connect, dom, query, parser, Map, Scalebar, arcgisUtils, Print, PrintTask,
   PrintTemplate, Popup, esriConfig, Attribution,
   domConstruct, domClass, mouse, Button, Menu, BorderContainer){
    parser.parse();

  esri.config.defaults.io.corsEnabledServers.push("mapservices.ssmic.com");

    var ext = new esri.geometry.Extent({ "xmin": -17529487, "ymin": 1874364, "xmax": -5084316, "ymax": 7500129, "spatialReference": { "wkid": 102100} });
    map = new esri.Map("map", {  
       extent: ext,
       showAttribution: false,
     });
    var tiled = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
    map.addLayer(tiled);

  //var kml = new KMLLayer("http://censusdemo.ssmic.com/kmzdata/Aboriginal%20Identity/Aboriginal%20Identities%20Not%20Included%20Elsewhere%20-%20Percent/2011/Census%20Divisions/AboriginalIdentity_AboriginalIdentitiesNotIncludedElsewhere-Percent_2011_CD.kmz", { id: "kml" });
  var kml = new KMLLayer("http://censusdemo.ssmic.com/tester.kml", { id: "kml" });
  map.addLayer(kml);

    // connect the dropdown list with options for the print template
    on(dom.byId("png"),'click', function () {
     printTaskSetup("MAP_ONLY", "png32");
    })   
    on(dom.byId("landscape"),'click', function () {
     printTaskSetup("A4 Landscape", "png32");
    })
    on(dom.byId("portrait"),'click', function () {
     printTaskSetup("A4 Portrait", "png32");
    })
    // create print task
    function printTaskSetup(layout, format){
     var template = new esri.tasks.PrintTemplate();
     template.format = format;
     template.layout = layout;
     template.layoutOptions = {
       "scalebarUnit": "Kilometers",
       "copyrightText": "",
       "showAttribution": false
     }
     template.preserveScale = true;
     var params = new esri.tasks.PrintParameters();
     params.map = map;
     params.template = template;
     printTask = new esri.tasks.PrintTask("http://mapservices.ssmic.com/production/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task", { async: true } );
     printTask.execute(params, printResult);
    }
    function printResult(result) {
      window.open(result.url, "_blank")
    }
    function printError(error) {
      alert(error);
    }
   }
  );
</script>
</html>

If I replace line 99 with the line above it ( which is link to a much more complex KML layer) then my GP Task times out after 10 minutes.

 

I've set up the PrintTools on my GeoProcessing server to be Asynchronous and have set the max records to 500,000 as seen here:

Utilities/PrintingTools (GPServer)

 

The only reason I can think of for why it times out this way is that the kml file in line 99 is 780KB in size and the KML file that causes the timeout is 4,742KB in size.

 

What am I doing wrong here?

Outcomes