Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

QueuedAioHttpTransport throwing ServerDisconnectedError/ClientOSError exceptions. #26

Open
bt-wil opened this issue Dec 6, 2017 · 2 comments

Comments

@bt-wil
Copy link

bt-wil commented Dec 6, 2017

Environment (python v3.6):

aiohttp==2.2.5
raven==6.1.0
raven-aiohttp==0.6.0
sentry==8.22.0

I tried using the QueuedAioHttpTransport for the transport and noticed that it generates errors if there are too many alerts firing.

#!/usr/bin/env python3
import asyncio
from functools import partial
import logging

import raven
from raven.handlers.logging import SentryHandler
from raven_aiohttp import QueuedAioHttpTransport


logging.basicConfig(
    format='[%(asctime)s] %(levelname)s - %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
    level=logging.INFO
)
LOG = logging.getLogger(__name__)


if __name__ == '__main__':
    loop = asyncio.get_event_loop()

    dsn = 'http://<key>:<secret>@localhost:9000/1'
    transport = partial(QueuedAioHttpTransport, workers=1, loop=loop, keepalive=True)

    client = raven.Client(dsn, transport=transport)
    handler = SentryHandler(client)
    handler.setLevel(logging.ERROR)
    logging.getLogger().addHandler(handler)

    for _ in range(2):
        LOG.error('test')

    loop.run_until_complete(client.remote.get_transport().close())
    loop.close()

Running the script produces:

[2017-12-06 12:10:30] ERROR - test
[2017-12-06 12:10:30] ERROR - test
[2017-12-06 12:10:30] ERROR - Sentry responded with an error: None (url: http://localhost:9000/api/1/store/)
Traceback (most recent call last):
  File "<lib-path>raven-aiohttp/raven_aiohttp.py", line 96, in _do_send
    timeout=self.timeout
  File "<env-path>/lib/python3.6/site-packages/aiohttp/helpers.py", line 97, in __iter__
    ret = yield from self._coro
  File "<env-path>/lib/python3.6/site-packages/aiohttp/client.py", line 241, in _request
    yield from resp.start(conn, read_until_eof)
  File "<env-path>/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 559, in start
    (message, payload) = yield from self._protocol.read()
  File "<env-path>/lib/python3.6/site-packages/aiohttp/streams.py", line 509, in read
    yield from self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None
b'Sentry responded with an error: None (url: http://localhost:9000/api/1/store/)'
[2017-12-06 12:10:30] ERROR - ['test']
b"['test']"

Sometimes, aiohttp.client_exceptions.ClientOSError would be thrown instead of aiohttp.client_exceptions.ServerDisconnectedError. Using AioHttpTransport as the transport did not cause any issue.

@hellysmile
Copy link
Contributor

Does messages in this case successfully send to the sentry on not?

@bt-wil
Copy link
Author

bt-wil commented Mar 15, 2018

No, the messages gets lost.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants