add missed read/write loop

1. _heartbeat_ tested
2. autoreconnect tested
3. need more test