Only set the attached flag when a client attaches (#3490)