add message to show listening, add error log, use the end function to disconnect the client