I am trying to the solve the route between 2 points and immediately buffering the route geometry.
I can able to solve the route by using the "Esri/resource-proxy" [sourcehttps://github.com/Esri/resource-proxy/releases], changed the proxy config [with routing URL, client id and client secret] and added proxy rule in my code.
Proxy rule:
urlUtils.addProxyRule({
urlPrefix: "tasks.arcgisonline.com",
proxyUrl: "http://xxxxx/DotNet/proxy.ashx"
});
I have been prompted with ArcGIS online signin popup with user name and password,
After successful authentication, I am passing the route geometry to do and show buffer. But I am getting below exception
"Unable to load http://xxxxx/DotNet/proxy.ashx?http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryS... status: 0"
This time I am setting ""esriConfig.defaults.io.alwaysUseProxy = false", but still this request is using proxy
Question 1: How to get rid of sign in popup? I assumed given client Id and client secret will not prompt popup.
Question 2: How to make buffer request with proxy?
Thanks
Murali
Murali,
See this blog post for help: Setting up a Proxy | Support Services Blog
<serverUrl url="http://route.arcgis.com" clientId="xxxx" clientSecret="xxxx" rateLimit="600" rateLimitPeriod="60" matchAll="true" /> <serverUrl url="http://traffic.arcgis.com" clientId="xxxx" clientSecret="xxxx" rateLimit="600" rateLimitPeriod="60" matchAll="true" /> <serverUrl url="http://tasks.arcgisonline.com" matchAll="true" />
Robert,
Thanks for your reply.
1. I already have 2 urls in my proxy config
<serverUrl url="http://route.arcgis.com" cliendId="xxxx" clientSecret="xxxxx" matchAll="true"/>
<serverUrl url="http://traffic.arcgis.com" cliendId="xxxx" clientSecret="xxxx" matchAll="true"/>
2. Sorry. My 2nd question is wrong. Actually I don't want to use my proxy for buffer [gemonetryService] .
Though I set "esriConfig.defaults.io.alwaysUseProxy = false" during my buffer request, it sill using the proxy.
Murali,
urlUtils.addProxyRule({
urlPrefix: "http://route.arcgis.com",
proxyUrl: "http://xxxxx/DotNet/proxy.ashx"
}, {
urlPrefix: "http://traffic.arcgis.com",
proxyUrl: "http://xxxxx/DotNet/proxy.ashx"
});
2. Remove the http://tasks.arcgisonline.com from the proxy.config and from the urlUtils.addProxyRule
Robert,
1. My routing is working perfectly. Please let me know how to get rid of arcgis log in popup before routing for token validation.
2. I have not added any entry for geometryservice in proxy.config and also no proxy rule in JS.
Please find my below doBuffercode
function doBuffer(geometry) {
require(['esri/tasks/BufferParameters', 'esri/tasks/GeometryService',
'esri/config', 'esri/geometry/normalizeUtils', 'esri/urlUtils', ],
function (BufferParameters, GeometryService, esriConfig, normalizeUtils, urlUtils) {
esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
esriConfig.defaults.io.proxyUrl = '/proxy/';
esriConfig.defaults.io.alwaysUseProxy = false;
//setup the buffer parameters
var params = new BufferParameters();
params.distances = [vmRoute.maxBufferRadius];
// params.bufferSpatialReference = { wkid: 4326 };
params.outSpatialReference = { wkid: 4326 }; //_map.spatialReference;
params.unit = GeometryService[vmRoute.bufferUnit.name];
esriConfig.defaults.geometryService.buffer(params, showBuffer);
});
}
Murali,
Again you need to add the rules to your JS code to tell the API to use the proxy for the route urls.
urlUtils.addProxyRule({
urlPrefix: "http://route.arcgis.com",
proxyUrl: "http://xxxxx/DotNet/proxy.ashx"
}, {
urlPrefix: "http://traffic.arcgis.com",
proxyUrl: "http://xxxxx/DotNet/proxy.ashx"
});
As long as you are using the clientId and clientSecret for your org in the proxy.config for the route and traffic url you should not receive a login prompt.
If you do not have http://tasks.arcgisonline.com in your proxy rules then it should not be re-directing though your proxy, so I am not sure what is wrong there.
Robert,
1. I have my proxy config with clientId and clientSecret for the route and traffic url. I also have urlUtils.addProxyRule for route in my JS since I am using routing alone for now. Still its prompting for my login popup, upon giving valid credentials I am getting the route without any issues.
2. As I said earlier I do not have task URL in proxy config and proxy rule in JS, but still my buffer request are re-directing through my proxy.
Appreciate any help on this.
Murali,
So have you open your browsers web tools and watched the network traffic to see what url is not making it through your proxy so that you are getting prompted for login?
I have cleared my browser cache and launched the app again. I am getting below exception now
And the response is
dojo.io.script.jsonp_dojoIoScript9._jsonpCallback({"error":{"code":499,"message":"Token Required","details":[]}});
It seems my proxy is not working now.