How to solve hanging and auto restart problem?