Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Python agent not sending error


#1

Edit (2018-09-26): In addition to the below:

  1. We got an error in the logfiles “Unable to report main transaction metrics after 5 successive attempts. Check the log messages and if necessary please report this problem to New Relic support for further investigation.”
  2. We do see instance in NewRelic where our application (an API) returned an “error” HTTP status: 406 and 403.

We’ve setup up NewRelic on a customer’s DEV environment. (The NR account belongs to our customer.) We saw a UnicodeEncodeError in Sentry (which we also have running in that application), but we didn’t see it in the NR dashboard.

Could it be related to the “AttributeError: ‘NoneType’ object has no attribute ‘peer_certificate’” that we also see happening (see below)? According to rpm newrelic com /accounts/1008852/applications/139190047 this should not be a problem, but that seems strange to me.

How to further debug this? Is there a command to check NR connectivity from the application (on the application server)?

###Python Agent Question Template

Permalink: https://rpm.newrelic.com/accounts/1008852/applications/139190047?tw[end]=1537878517&tw[start]=1537876717

  • What language agent version are you using? Any other relevant versions? (Packages, etc.)

4.2.0.100 on python2.7

  • What error message are you seeing if any? Paste in text or add a screenshot:

    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xc9’ in position 14: ordinal not in range(128)
    DEBUG 2018-09-25 14:14:32,359 ecommerce.utils.sentry.MyDjangoClient Sending message of length 13342 to https://sentry.io/api/1256748/store/
    INFO 2018-09-25 14:14:32,360 requests.packages.urllib3.connectionpool Starting new HTTPS connection (1): sentry.io
    /usr/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuri
    ng SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
    InsecurePlatformWarning
    DEBUG 2018-09-25 14:14:33,112 requests.packages.urllib3.connectionpool “POST /api/1256748/store/ HTTP/1.1” 200 41
    [pid: 7999|app: 0|req: 178/992] 192.168.128.36 () {48 vars in 792 bytes} [Tue Sep 25 14:14:23 2018] POST /api/food/articles-import/ => generated 2247 bytes in 9970 msecs (HTTP/1.1 5
    00) 4 headers in 135 bytes (1 switches on core 0)
    [pid: 7993|app: 0|req: 132/993] 192.168.128.84 () {34 vars in 398 bytes} [Tue Sep 25 14:14:33 2018] GET /api/ => generated 875 bytes in 5 msecs (HTTP/1.1 200) 5 headers in 150 bytes
    (1 switches on core 0)
    [pid: 7998|app: 0|req: 103/994] 192.168.128.36 () {34 vars in 398 bytes} [Tue Sep 25 14:14:41 2018] GET /api/ => generated 875 bytes in 5 msecs (HTTP/1.1 200) 5 headers in 150 bytes
    (1 switches on core 0)
    [pid: 7996|app: 0|req: 123/995] 192.168.128.84 () {34 vars in 398 bytes} [Tue Sep 25 14:14:43 2018] GET /api/ => generated 875 bytes in 4 msecs (HTTP/1.1 200) 5 headers in 150 bytes (1 switches on core 0)
    [pid: 8000|app: 0|req: 146/996] 192.168.128.36 () {50 vars in 907 bytes} [Tue Sep 25 14:14:46 2018] GET /api/basket/ => generated 274 bytes in 62 msecs (HTTP/1.1 200) 7 headers in 372 bytes (1 switches on core 0)
    [pid: 7999|app: 0|req: 179/997] 192.168.128.36 () {34 vars in 398 bytes} [Tue Sep 25 14:14:51 2018] GET /api/ => generated 875 bytes in 6 msecs (HTTP/1.1 200) 5 headers in 150 bytes (1 switches on core 0)
    [pid: 7993|app: 0|req: 133/998] 192.168.128.84 () {34 vars in 398 bytes} [Tue Sep 25 14:14:53 2018] GET /api/ => generated 875 bytes in 4 msecs (HTTP/1.1 200) 5 headers in 150 bytes (1 switches on core 0)
    INFO 2018-09-25 14:15:00,942 ecommerce.cron Starting sending emails
    ERROR 2018-09-25 14:15:00,943 newrelic.core.data_collector Unexpected exception when attempting to register the agent with the data collector. Please report this problem to New Relic support for further investigation.
    Traceback (most recent call last):
    File “/usr/lib/python2.7/dist-packages/newrelic/core/data_collector.py”, line 1062, in create_session
    ‘preconnect’, license_key)
    File “/usr/lib/python2.7/dist-packages/newrelic/core/data_collector.py”, line 830, in send_request
    agent_run_id, payload, max_payload_size_in_bytes)
    File “/usr/lib/python2.7/dist-packages/newrelic/core/data_collector.py”, line 455, in send_request
    verify=cert_loc)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/sessions.py”, line 504, in post
    return self.request(‘POST’, url, data=data, json=json, **kwargs)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/sessions.py”, line 461, in request
    resp = self.send(prep, **send_kwargs)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/sessions.py”, line 573, in send
    r = adapter.send(request, **kwargs)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/adapters.py”, line 370, in send
    timeout=timeout
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/packages/urllib3/connectionpool.py”, line 518, in urlopen
    body=body, headers=headers)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/packages/urllib3/connectionpool.py”, line 322, in _make_request
    self._validate_conn(conn)
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/packages/urllib3/connectionpool.py”, line 727, in _validate_conn
    conn.connect()
    File “/usr/lib/python2.7/dist-packages/newrelic/packages/requests/packages/urllib3/connection.py”, line 245, in connect
    cert = self.sock.getpeercert()
    File “/usr/lib/python2.7/ssl.py”, line 281, in getpeercert
    return self._sslobj.peer_certificate(binary_form)
    AttributeError: ‘NoneType’ object has no attribute ‘peer_certificate’

  • Describe what are you seeing? How does that differ than what were you expecting to see?

No exceptions from the application are visible in the NewRelic dashboard. I would expect to see the UnicodeEncodeError. The NewRelic application doesn’t seem to have problems accepting connections form our application, as it correctly uses the Application Name from newrelic.ini.


#2

@kees Thank you for those details! I’d like to gather some additional information, better shared in private, to help in our investigation, so I’ve gone ahead and opened a ticket for you.