more robust input stream parsing (avoid getting hung up on invalid messages)