Allow specification of message size
Improved handling of connection failure