Added the error handlers to avoid cutting off connection on error