I have sort of given up in fixing the problem, and will instead work on auto-detecting and auto-recovering when the problem happens.