Esri / resource-proxy

Proxy files for DotNet, Java and PHP.
Apache License 2.0
371 stars 322 forks source link

Uncaught SyntaxError: Unexpected token } in JSON at position #523

Closed anakaine closed 3 years ago

anakaine commented 5 years ago

A fresh install of PHP resource proxy with a fresh, simple ESRI-Leaflet map that works without error providing no proxy'd address is used. Once a feature service is used with the proxy the following error is returned. So far I've been unable to locate where the issue is arising from. The logical things like checking for duplicate or absent list elements, line terminations, etc, isn't giving me much joy.

The browser error in Chrome is: Uncaught SyntaxError: Unexpected token } in JSON at position xxx The returned line in question is: {"https://serveraddress/arcgis/rest/services/name/FeatureServer/0"} The closing } is flagged as the source of the error.

The layer is being called via:

    // create a feature layer and add it to the map
    var pedestrianDistricts = L.esri.featureLayer({
      url: 'http://ipaddress/mapproxy/proxy.php?https://serveraddress/arcgis/rest/services/name/FeatureServer/0'
    }).addTo(map);

The proxy.config looks like:

<?xml version="1.0" encoding="utf-8" ?>
     <ProxyConfig allowedReferers="*"
             logLevel="1"
             logFile="proxy_log.log"
             mustMatch="true">
    <serverUrls>
        <serverUrl url="http://services.arcgisonline.com"
                   matchAll="true"/>
    <serverUrl url="http://serveraddress"
                   matchAll="true"
           username="exampleuser"
           password="examplepassword"
           rateLimit="120"
           rateLimitPeriod="60"/>
    </serverUrls>
</ProxyConfig>

So far as I can tell theres no issue collecting the token. The console is free of other errors, and the log file looks like:

06-24-19 09:29:22 | GET detected
06-24-19 09:29:22 | ips table created!
06-24-19 09:29:22 | clicks table created!
06-24-19 09:29:22 | Resource using ArcGIS Server security
06-24-19 09:29:22 | Got token endpoint
06-24-19 09:29:22 | Adding token to session
06-24-19 09:29:22 | Ok to proxy
06-24-19 09:29:22 | Proxy complete

06-24-19 09:36:59 | GET detected
06-24-19 09:36:59 | Using session token
06-24-19 09:36:59 | Ok to proxy
06-24-19 09:36:59 | Proxy complete

The php version of the script is: 1.1.2

From php-verification.php: Check PHP version 5.6 or newer? | Pass [v7.3.4] Check if directory is writable? | Pass Check for PDO Sqlite extension? | Pass Check for Curl? | Pass [v.7.61.1]

ahmednoureldeen commented 4 years ago

Proxy url must be passed as a separate parameter, as the below example:

// create a feature layer and add it to the map
    var pedestrianDistricts = L.esri.featureLayer({
      proxy: 'http://ipaddress/mapproxy/proxy.php',
      url: 'https://serveraddress/arcgis/rest/services/name/FeatureServer/0'
    }).addTo(map);
anakaine commented 4 years ago

That's great, thanks

On Wed, 27 May 2020, 22:01 Ahmed Nour Eldeen, notifications@github.com wrote:

Proxy url must be passed as a separate parameter, as the below example:

// create a feature layer and add it to the map var pedestrianDistricts = L.esri.featureLayer({ proxy: 'http://ipaddress/mapproxy/proxy.php', url: 'https://serveraddress/arcgis/rest/services/name/FeatureServer/0' }).addTo(map);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Esri/resource-proxy/issues/523#issuecomment-634612968, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWLFS4V52PU3PKHIFXZ3KDRTT6IHANCNFSM4H25EMHA .

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you need additional assistance please contact Esri Technical Support. Thank you for your contributions.

github-actions[bot] commented 3 years ago

This issue has been automatically closed due to inactivity. If you need additional assistance please contact Esri Technical Support.