Corrected disconnecting after getting invalid query header error