Skip to content

Commit

Permalink
better log message for socketio errors
Browse files Browse the repository at this point in the history
  • Loading branch information
htouvet committed Jan 11, 2018
1 parent e7e7507 commit 1fd610d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions waptserver/waptserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,6 @@ def on_waptclient_connect():
host_certificate = SSLCertificate(crt_string=host_cert.host_certificate)
host_cert_issuer = host_certificate.verify_claim(json.loads(request.args['login']), max_age_secs=app.conf['signature_clockskew'],required_attributes=['uuid'])
logger.debug(u'Socket IO %s connect checked. issuer : %s' % ( request.sid,host_cert_issuer))
pass
else:
raise EWaptForbiddden('Host is not registered or no host certificate found in database.')

Expand All @@ -2018,17 +2017,19 @@ def on_waptclient_connect():
raise EWaptForbiddden('Host is not registered')

except Exception as e:
logger.debug(u'Connect refused: %s' % e)
logger.warning(u'SocketIO connection refused for uuid %s and sid %s : %s' % (uuid,request.sid,e))
wapt_db.rollback()
wapt_db.close()
return False


@socketio.on('wapt_pong')
def on_wapt_pong():
uuid = None
try:
uuid = session.get('uuid')
if not uuid:
logger.critical(u'SocketIO connected but no host uuid in session: asking connected host to update status' % (uuid,request.sid))
emit('wapt_trigger_update_status')
return False
else:
Expand All @@ -2044,12 +2045,12 @@ def on_wapt_pong():
wapt_db.commit()
# if not known, reject the connection
if hostcount == 0:
logger.warning(u'SocketIO sid %s connected but no match in database for uuid %s : asking to update status' % (request.sid,uuid))
emit('wapt_trigger_update_status')
return False
except Exception as e:
print('Socket.IO error in wapt_pong %s' % traceback.format_exc())
wapt_db.rollback()

logger.critical(u'SocketIO pong error for uuid %s and sid %s : %s' % (uuid,request.sid,traceback.format_exc()))

@socketio.on('disconnect')
def on_waptclient_disconnect():
Expand Down

0 comments on commit 1fd610d

Please sign in to comment.