HVDC has been playing an important role in long distance transmission. As the principle problem of traditional thyristor HVDC, commutation failure become more serious in modern large grid. Firstly, This paper analyzed the commutation process and mechanism of commutation failure in details. Then the effective controller is presented to prevent commutation failure under symmetric and asymmetric faults. The key parameter “gain” of the controller is optimized by the nonlinear method Hooke-Jeeves of which the objective function is the inverter bus voltage deviation. Finally, the simulation result shows that the proposed method not only improves the immunity of commutation failure, but also reduces the fluctuations of system state variables.