I am writing a Python module to use the InterMapper HTTP API to retrieve the device list. I am getting "Connection reset by peer" error.
Here is my code section that uses usrlib2 and cookielib -- This is only the function opening a URL to retrieve a table but it should be fairly self-explanatory: Code: def __get(self, accss, name): ''' Open an HTTP/S connection to a given server (accss) to retrieve a table (name) in tab-delimited text format. Returns response to the open URL, to be read by the caller, if successful; Or None if failed. ''' url = accss['url']+'/~export/'+name+'.tab' fields = self.C.get('fields') if fields: fields = fields.get(name) logging.debug('URL = '+url) try: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(accss['cookiejar'])) headers = { "Authorization": "Basic "+base64.encodestring(accss['user']+':'+accss['password'])[:-1], 'User-agent' : 'Mozilla/5.0' } request = urllib2.Request(url, fields, headers) return opener.open(request) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() logging.debug(repr(traceback.extract_tb(exc_traceback))) logging.error('action="Connecting to InterMapper server - URL = %s" message=FAILED error="%s - %s"', url,e.__class__.__name__,str(format(e))) return None After "response = self.__get(accss, 'devices')", "response.read()" would throw a socket error - [Errno 104] Connection reset by peer Thanks in advance. Any tips, thoughts are very much appreciated. Code: -------------------- m2f -------------------- Read this topic online here: http://forums.intermapper.com/viewtopic.php?p=4302#4302 ____________________________________________________________________ List archives: http://www.mail-archive.com/intermapper-talk%40list.dartware.com/ To unsubscribe: send email to: intermapper-talk-...@list.dartware.com