TeamCity REST API intermittently fails for JSON requests

Hello,

We have a python script to trigger build runs automatically based on some project name matching criteria.
It has been working for a month or so but has recently started to fail (approximately sometime last week).
The actual failure occurs when trying to get the url http://teamcity:8111/httpAuth/app/rest/projects/id:(PROJECTHERE)  in JSON format (by use of headers).

The failure is intermittent,  sometimes it succeeds, other times it fails.


Example stack traces from  script:

for all versions...
Traceback (most recent call last):
  File "/Users/bryan/bin/tc_releaser.py", line 105, in <module>
    main()
  File "/Users/bryan/bin/tc_releaser.py", line 101, in main
    tc_releaser(username, password, args.application, None, args.builds)
  File "/Users/bryan/bin/tc_releaser.py", line 68, in tc_releaser
    builds = retrieve_builds(None, application, all_builds)
  File "/Users/bryan/bin/tc_releaser.py", line 42, in retrieve_builds
    for project in get_json(TC_PROJ)['project']:
  File "/Users/bryan/bin/tc_releaser.py", line 25, in get_json
    return json.load(urllib2.urlopen(urllib2.Request(a_url, None, {'Accept': 'application/json'})))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 394, in open
    response = self._open(req, data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 412, in _open
    '_open', req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1199, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1174, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 54] Connection reset by peer>


The function we use to build the JSON request and get its result is:

def get_json(a_url):
    return json.load(urllib2.urlopen(urllib2.Request(a_url, None, {'Accept': 'application/json'})))

where for example:
a_url = "http://teamcity:8111/httpAuth/app/rest/projects/id:project712"


The teamcity-rest.log or any other log does not seem to mention anything relative.
Any idea what might be going wrong?


Thank you,
Nantia

3 comments
Comment actions Permalink

Hi Nantia,


> Connection reset by peer
> The teamcity-rest.log or any other log does not seem to mention anything relative.

The most probable reason is that the request is not reaching TeamCity at all, ending somewhere in between. I'd check for firewalls, proxies, anti-virus software and alike.

If all other requests with the same headers are sent OK to TeamCity and only this fails, please enable rest debug logging preset and check if anything is logged to teamcity-rest.log or teamcity-server.log on the request

0
Comment actions Permalink

Mnay thanks, we ll double check.


0
Comment actions Permalink

Thanks Yegor, it seems it was a network problem indeed, some settings in one of our WAN appliances.
Many thanks for your time.

Regards
Nantia

0

Please sign in to leave a comment.