added missing check for attachment api
changed connection exception to socket exception for socket close