Added payload limit validation and handle remote socket close.