Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert create error: ('Connection aborted.', error(104, 'Connection reset by peer') #109

Closed
tr0mb1r opened this issue Mar 20, 2019 · 1 comment

Comments

@tr0mb1r
Copy link

tr0mb1r commented Mar 20, 2019

Request Type

Bug

Work Environment

Question Answer
OS version (server) Debian
TheHive4py version / git hash 1.6.0

Problem Description

Traceback (most recent call last):
    response = self.api.create_alert(alert)
  File "/usr/lib/python2.7/site-packages/thehive4py/api.py", line 422, in create_alert
    raise AlertException("Alert create error: {}".format(e))
thehive4py.exceptions.AlertException: Alert create error: ('Connection aborted.', error(104, 'Connection reset by peer'))

Possible Solutions

The solution for now i use is:

def createAlert(self, alert):
    alertId = None
    try:
        response = self.api.create_alert(alert)
        if response.status_code == 201:
            alertId = response.json()['id']
            logging.info('Alert created: ' + alertId)
        else:
            logging.error('Alert creation failed.')
    except:
        logging.error('Alert creation failed. Will make 3 retries.')
        fail = True
        tries = 0
        while fail and tries != 3:
            response = self.api.create_alert(alert)
            if response.status_code == 201:
                fail = False
                alertId = response.json()['id']
                logging.info('Alert created: ' + alertId)
            else:
                tries += 1
                logging.error('Alert creation failed. Try #: '+str(tries))
    return alertId

And it creates alert with the first try on exception.

@tr0mb1r
Copy link
Author

tr0mb1r commented Mar 20, 2019

Seems to be solved with rising of Entity size limit

@tr0mb1r tr0mb1r closed this as completed Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant