Adding an error handler for the tls socket connection