Export Web Map Task Error: "Unable to connect to map server..."

10777
22
05-02-2012 05:53 AM
AR
by
New Contributor III
I receive this error anytime I try to print any base map from http://services.arcgisonline.com.

If I remove the base map from my code, it prints fine.

(From Firebug console:)
"Error executing tool.: Layer "layer0": Unable to connect to map server at http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task)."

I get a gut-feeling it has something to do with my server's proxy, but I'm not sure.

Any thoughts?

Here is the proxy I'm using:

<%@page session="false"%>
<%@page import="java.net.*,java.io.*" %>
<%!
String[] serverUrls = {
  //"<url>[,<token>]"
  //For ex. (secured server): "http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a"
  //For ex. (non-secured server): "http://sampleserver1.arcgisonline.com/arcgis/rest/services"
  "http://sampleserver1.arcgisonline.com/arcgis/rest/services",
  "http://***/arcgis/rest/services, username=***",// username=***
  "http://server.arcgisonline.com/ArcGIS/rest/services",
  "http://***/ArcGIS/rest/services, username=***&password=***",
  "http://servicesbeta4.esri.com/arcgis/rest/services/",
  "http://sampleserver2.arcgisonline.com/arcgis/rest/services" 
};
%>
<%
try {
  String reqUrl = request.getQueryString();
  boolean allowed = false;
  String token = null;
  for(String surl : serverUrls) {
    String[] stokens = surl.split("\\s*,\\s*");
    if(reqUrl.toLowerCase().contains(stokens[0].toLowerCase())) {
      allowed = true;
      if(stokens.length >= 2 && stokens[1].length() > 0)
        token = stokens[1];
      break;
    }
  }
  if(!allowed) {
    response.setStatus(403);
    return;
  }
  if(token != null) {
    reqUrl = reqUrl + (reqUrl.indexOf("?") > -1 ? "&" : "?") + "token=" + token;
  }
  URL url = new URL(reqUrl);
 HttpURLConnection con = (HttpURLConnection)url.openConnection();
 con.setDoOutput(true);
 con.setRequestMethod(request.getMethod());
 if(request.getContentType() != null) {
   con.setRequestProperty("Content-Type", request.getContentType());
 }
  con.setRequestProperty("Referer", request.getHeader("Referer"));
 int clength = request.getContentLength();
 if(clength > 0) {
  con.setDoInput(true);
  InputStream istream = request.getInputStream();
  OutputStream os = con.getOutputStream();
  final int length = 5000;
   byte[] bytes = new byte[length];
   int bytesRead = 0;
   while ((bytesRead = istream.read(bytes, 0, length)) > 0) {
     os.write(bytes, 0, bytesRead);
   }
 }
  else {
    con.setRequestMethod("GET");
  }
 out.clear();
  out = pageContext.pushBody();
 OutputStream ostream = response.getOutputStream();
 response.setContentType(con.getContentType());
 InputStream in = con.getInputStream();
 final int length = 5000;
  byte[] bytes = new byte[length];
  int bytesRead = 0;
  while ((bytesRead = in.read(bytes, 0, length)) > 0) {
    ostream.write(bytes, 0, bytesRead);
  }
} catch(Exception e) {
 response.setStatus(500);
}
%>


22 Replies
AndyGup
Esri Regular Contributor
@roessera here are some guidelines to help verify what's going on when a proxy doesn't seem to be working:

- Make sure you have the latest version of the ArcGIS proxy.
- Make sure that the Server URL properties are configured properly.
- If you are using tokens, follow the directions for the appropriate proxy (.jsp, ashx or php) for allowing tokens.
- Check the Proxy's web server log files. You may have to turn on full logging first. And, don't forget to disable full logging after you are done testing. If the proxy can't connect to ArcGIS Server you should be able to see an error in the web server log.
- As a last resort, run an HTTP protocol analyzer on the proxy server, for example WireShark. This will let you see and analyze the inbound and outbound HTTP connections.


-Andy
0 Kudos
KyleDixon
Occasional Contributor
The problem is that our network uses a proxy to access the internet, the web server can't access arcgisonline. How do I configure the server to use a web proxy.

We are using arcserver 10.1
0 Kudos
AndyGup
Esri Regular Contributor
Hi Kyle,

There are three likely scenarios.

1) Configuring an ArcGIS Proxy and making sure it's working. This will allow your applications to access GIS services such as http://services.arcgisonline.com. My previous suggestions relate to this scenario.

2) Configuring your organization's network dmz/proxy/firewall. For this you'll have to talk to your organization's network/IT engineers. They will have to configure your network proxy, DMZ or firewall that allows connections between the ArcGIS Proxy and http://services.arcgisonline.com.

3) Configuring proxy access to your ArcGIS Server. You also mentioned you have ArcGIS Server. If you have external applications that need to access your ArcGIS Server GIS services, then you'll also have to work with your network/IT engineers. We consider this an enterprise-level, third party deployment and offer professional services to help architect and configure reverse proxy configurations. Here's a few links that can help with this scenario.

Configure a reverse proxy system architecture with ArcGIS Server
Configure a reverse proxy system architecture for ArcGIS Server with IIS 7

I hope that helps,

-Andy
0 Kudos
by Anonymous User
Not applicable

do you can help me please?

I trying use the print widget from Arcgis Flex viewer and get the same message.

Any considerations

The map servicesis visible without problem in the viewer in local and print widget is working ok

When i access to viewer from internet  the map service is ok but the print  widget not working and i get the message

[RPC Fault faultString="Unable to complete operation." faultCode="400" faultDetail="Error executing tool.: Layer "carto base": Unable to connect to map server athttp://186.47.xx.xx:6080/arcgis/rest/services/carto_base/MapServer.

Failed to execute (Export Web Map).

Failed to execute (Export Web Map Task)."]

The team of network/it say that the access to map services is open

What is the permissions that the map services need enable in firewall or proxy?

Thanks

KyleDixon
Occasional Contributor
I'm not trying to access from server from the internet, I need configure the server for access to the internet.

The user arcgis that is running the print services cannot access arcgisonline.com.

I need to configure these settings for the arcgis user.
[ATTACH=CONFIG]14205[/ATTACH]
0 Kudos
KyleDixon
Occasional Contributor
I found this:
http://resourcesbeta.arcgis.com/en/help/main/10.1/0154/015400000309000000.htm

I confirmed the proxy is configured, but it still isn't working.
0 Kudos
by Anonymous User
Not applicable
Kyle,

I did notice that you've not added  "http://services.arcgisonline.com/ArcGIS/rest/services" to the serverUrls string array in the Java proxy. 

If the "http://services.arcgisonline.com/ArcGIS/rest/services" is not found in this array no requests will be forwarded onward to services hosted in http://services.arcgisonline.com.

This may be the problem.  Try adding this URL to the string array.

After doing so, if this does not work can you please send the URL and full request which is associated with the below error message?

"Error executing tool.: Layer "layer0": Unable to connect to map server at http://services.arcgisonline.com/Arc...Base/MapServer. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task)."

Regards,
Doug Carroll, ESRI Support Services SDK Team
http://support.esri.com/
0 Kudos
KyleDixon
Occasional Contributor
We aren't using services.arcgisonline, I added http://services.arcgisonline.com/ArcGIS/rest/services to the java proxy and it didn't work.
The full request is attached.
0 Kudos
by Anonymous User
Not applicable
Looks like I read "http://services.arcgisonline.com/ArcGIS/rest/services" based on the first thread. 

Anyhow, can you give more details about the problem?  In the printout are you able to see the map features from the service that is hosted locally or is it just that map features from http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer that are missing? 

Also what happens if you open a web browser on darcgis1 and go to  http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?  Are you able to see the REST endpoint?

Also at one point did you have both Beta2 and Pre Release on the same machine?  Please let me know?


Regards,
Doug Carroll, ESRI Support Services SDK Team
http://support.esri.com/
0 Kudos