Rename max_msglen as payload_limit
Add payload_limit parameter