URLError: <urlopen error [Errno 10054] An existing connection was forcibly closed by the remote host>

2104
2
05-30-2019 08:52 AM
JoseSanchez
Occasional Contributor III

Hello everyone,

We get the following error message:

URLError: <urlopen error [Errno 10054] An existing connection was forcibly closed by the remote host>

when running the function below :

def generateToken():
   
    print "Generating Token"
    tokenURL = "https://arcgis.com/sharing/rest/generateToken"
    data = {'username': PortalUtil.getAGOLUserName(),
        'password': PortalUtil.getAGOLPassword(),
        'referer': "https://www.arcgis.com",
        'f': 'json'}
   
    encodedData = urllib.urlencode(data)
    tokenRequest = urllib2.Request(tokenURL, encodedData)   
    tokenResponse = urllib2.urlopen(tokenRequest)
    tokenResponseJSON = json.load(tokenResponse)

    print (tokenResponseJSON['token'])
 
    return tokenResponseJSON['token']   
   

token = generateToken()

 

0 Kudos
2 Replies
NoelPerkins3
New Contributor III

Jose - were you able to find a resolution to this? We are having the same issue.

0 Kudos
JoseSanchez
Occasional Contributor III

WE updated ArcGIS server from 10.4.x to 10.6.x  and the issue was fixed. The new library in version 10.6 worked.