Add log for encode/decode message.
Correct keepalive logic.