Automagically Detect and Use Windows Proxy settings

3111
6
Jump to solution
10-06-2015 12:43 PM
JohnDye
Occasional Contributor III

i'm doing my the first Qt tutorial (Add a map to your app) but sit behind a firewall that is configured in in the standard Windows Internet options. When I build the solution, If I'm using an ArcGISTiledMapServiceLayer for the basemap, it doesn't show. I assume this is because the request needs to be sent through our proxy.

How can I tell the Qt app to detect and use the default proxy settings configured for the user in windows?

main.qml

// Copyright 2015 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//


import QtQuick 2.3
import QtQuick.Controls 1.2
import ArcGIS.Runtime 10.26

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600
    title: "Add a map to your app"


    Map {
        anchors.fill: parent


        focus: true


        ArcGISTiledMapServiceLayer {
            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
        }
    }
}

It works fine when using the ArcGISLocalTiledLayer though and I was able to get through the tutorial with that.

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Hi John-

You need to setup the proxy with ArcGISRuntime::setUpProxy - ArcGIS Runtime SDK for Qt QML API: ArcGISRuntime Class Reference

For example, something like the following should do the trick:

import QtQuick 2.3
import QtQuick.Controls 1.2
import ArcGIS.Runtime 10.26


ApplicationWindow {
    id: appWindow
    width: 800
    height: 600


    Component.onCompleted: {
        ArcGISRuntime.setupProxy("http://127.0.0.1:8888"); // add your own URL and port
    }


    Map {
        anchors.fill: parent


        focus: true


        ArcGISTiledMapServiceLayer {
            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
        }
    }
}










View solution in original post

6 Replies
LucasDanzinger
Esri Frequent Contributor

Hi John-

You need to setup the proxy with ArcGISRuntime::setUpProxy - ArcGIS Runtime SDK for Qt QML API: ArcGISRuntime Class Reference

For example, something like the following should do the trick:

import QtQuick 2.3
import QtQuick.Controls 1.2
import ArcGIS.Runtime 10.26


ApplicationWindow {
    id: appWindow
    width: 800
    height: 600


    Component.onCompleted: {
        ArcGISRuntime.setupProxy("http://127.0.0.1:8888"); // add your own URL and port
    }


    Map {
        anchors.fill: parent


        focus: true


        ArcGISTiledMapServiceLayer {
            url: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
        }
    }
}










JohnDye
Occasional Contributor III

Thanks Lucas!,

I actually did find that in the Runtime docs but wasn't aware of the Component.onCompleted piece. While this makes sense and for most it is probably the right answer, it didn't work for me after I inserted our proxy url and port.

I then updated the proxy to localhost and fired up fiddler to see if I could get any insight from the network requests. Tunneling through Fiddler it worked fine, but once I closed Fiddler I lost the WebMap again if I rebuilt the solution.

0 Kudos
by Anonymous User
Not applicable

Not sure if helpful, but try the following - it worked for us.

if(AppFramework.network.proxy.type !== 2) {ArcGISRuntime.setupProxy(AppFramework.network.proxy.url) }

How to detect if a network proxy is being used?

JohnDye
Occasional Contributor III

Paul, where are you referencing AppFramework from? I tried to import it but that didn't work.

Update:

Looked up AppFramework, seems to be something specific to AppStudio which I'm not using.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

If you are using 127.0.0.1, it will only work when you have a local proxy running like fiddler. Otherwise, it is telling the API to run things through the proxy, but that proxy isn't actually running, and the network requests will never make it out.

DanPatterson_Retired
MVP Emeritus

automagically ... kudos, I love to see a neologism enter the wider idiolect 🙂

0 Kudos