fix data->buf
add length header
fix try
fix condition