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

Error after latest update on tanner's develop branch #253

Closed
viskey98 opened this issue Jun 11, 2018 · 3 comments
Closed

Error after latest update on tanner's develop branch #253

viskey98 opened this issue Jun 11, 2018 · 3 comments

Comments

@viskey98
Copy link
Collaborator

Lately when I tried run to snare and tanner to check the working of latest updates, i faced a problem. This problem seems to happen when snare sends data to tanner after (75+ secs) expiry of the session.

  • It's like, when i create a session in snare, browse for a while and leave it idle for 75+ secs and try to create a new session ( because, the old session stats will be sent to tanner, so that i can analyze it).
  • I get 500 Internal server error on the browser. And when i open the snare.err file I found this :
2018-06-11 12:47:24 ERROR:aiohttp.server:log_exception: Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 385, in start
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_app.py", line 338, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_middlewares.py", line 88, in impl
    return await handler(request)
  File "/usr/local/lib/python3.6/dist-packages/Snare-0.2.0-py3.6.egg/snare/middlewares.py", line 21, in error_middleware
    response = await handler(request)
  File "/usr/local/lib/python3.6/dist-packages/Snare-0.2.0-py3.6.egg/snare/server.py", line 50, in handle_request
    event_result = await self.tanner_handler.submit_data(data)
  File "/usr/local/lib/python3.6/dist-packages/Snare-0.2.0-py3.6.egg/snare/tanner_handler.py", line 62, in submit_data
    raise e
  File "/usr/local/lib/python3.6/dist-packages/Snare-0.2.0-py3.6.egg/snare/tanner_handler.py", line 56, in submit_data
    event_result = await r.json()
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client_reqrep.py", line 927, in json
    headers=self.headers)
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'
  • On the tanner's side i found this on tanner.err:
2018-06-11 14:10:34 ERROR:aiohttp.server:log_exception: Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 422, in start
    timeout = min(end_t - now, lingering_time)
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/web.py", line 306, in _handle
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/server.py", line 60, in handle_event
    data, self.redis_client
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_manager.py", line 17, in add_or_update_session
    await self.delete_old_sessions(redis_client)
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_manager.py", line 72, in delete_old_sessions
    is_deleted = await self.delete_session(sess, redis_client)
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_manager.py", line 91, in delete_session
    await self.analyzer.analyze(sess.get_uuid(), redis_client)
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_analyzer.py", line 28, in analyze
    result = await self.create_stats(session, redis_client)
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_analyzer.py", line 49, in create_stats
    None, self.find_location, session['peer']['ip']
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/dist-packages/Tanner-0.5.0-py3.6.egg/tanner/session_analyzer.py", line 143, in find_location
    location = reader.city(ip)
  File "/usr/lib/python3/dist-packages/geoip2/database.py", line 110, in city
    return self._model_for(geoip2.models.City, 'City', ip_address)
  File "/usr/lib/python3/dist-packages/geoip2/database.py", line 191, in _model_for
    record = self._get(types, ip_address)
  File "/usr/lib/python3/dist-packages/geoip2/database.py", line 187, in _get
    "The address %s is not in the database." % ip_address)
geoip2.errors.AddressNotFoundError: The address ::1 is not in the database.

I think this occurs because the database only contains public IP addresses, and if we create sessions from Private IP addresses, we face this error.

@viskey98
Copy link
Collaborator Author

I will work on this issue myself :)

@viskey98 viskey98 changed the title Error in snare-tanner communication after tanner's latest update Error after latest update on tanner's develop branch Jun 11, 2018
@viskey98 viskey98 mentioned this issue Jun 11, 2018
afeena pushed a commit that referenced this issue Jun 11, 2018
* fix

* Minor change

* Improve cover
@viskey98
Copy link
Collaborator Author

Fixed by #254

afeena pushed a commit to afeena/tanner that referenced this issue Jul 12, 2018
* fix

* Minor change

* Improve cover
viskey98 added a commit to viskey98/tanner that referenced this issue Jul 12, 2018
* fix

* Minor change

* Improve cover
@1llusionary
Copy link

@viskey98 Hi, I have met the same error. Have you resolve it?

<aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'>

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

2 participants