[GIS] Error executing tool.: Layer “layer1” Unable to connect to map server

arcgis-10.2arcgis-javascript-apiarcgis-serverprintingPROXY

I am using the Configurable Javascript Viewer, and have only changed a couple of the configuration settings.

One change I made was to use my own Export Web Map Task.

In viewer.js, I changed:

printTaskURL: 'http://maps.evansvillegis.com/arcgis_server/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task'

I then saw this note in the readme.md in the proxy directory:

You will more than likely need a proxy page for printing and other large cross domain requests.

So, I set that up using the provided proxypage_net.zip files, proxy.ashx and proxy.config.

In proxy.config, I added:

<serverUrl url="http://maps.evansvillegis.com"
           matchAll="true"></serverUrl>

Then I made sure my viewer.js file pointed to the current proxyUrl:

esriConfig.defaults.io.proxyUrl = 'proxypage_net/proxy.ashx';

However, when I try to print, I am getting the following error in the response:

{"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool.: Layer \"layer1\": Unable to connect to map server at http://maps.evansvillegis.com/arcgis_server/rest/services/BASEMAPS/BASEMAP_GOOGLE_WGS84_NO_FOOTPRINTS_BW/MapServer.\nFailed to execute (Export Web Map).\nFailed to execute (Export Web Map Task)."]}}

I have seen related posts:

Secure Print Service Failed to Execute

ArcGIS Online printing Unable to connect to map server?

However, the provided information (mind you, limited) was not much help.

The 400 error – is this because my proxy is not setup correctly, or is there something wrong with my PrintTask service?

This is the default PrintTask that is configured with ArcGIS Server 10.2.1. The only other change I have made, is ensuring IIS users and the ArcGIS Server Account can access the ArcGIS Server directories.

Viewer: http://maps.evansvillegis.com/viewer

Best Answer

It might be the proxy setup, or it might be the code inside the JS you used.

There is a proxy parameter esriConfig.defaults.io.alwaysUseProxy. Try setting it to false. You can read about the proxy page here: https://developers.arcgis.com/javascript/jshelp/ags_proxy.html

Also you can add more serverUrls to your config since the basemap request goes to your defined server. The example is, for example, here: http://www2.microstrategy.com/producthelp/AnalyticsEnterprise/GISHelp/Lang_1033/topics/ESRIOnPremisesIntegration/ESRI_OnPremises_UseProxyServer.htm