fix file path to save and set timeout to force closing socket.