diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 1956f3119d..431be5b4dc 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -676,8 +676,10 @@ bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint32_t message_type) } } - this->client_->add(reinterpret_cast(header.data()), header.size()); - this->client_->add(reinterpret_cast(buffer.get_buffer()->data()), buffer.get_buffer()->size()); + this->client_->add(reinterpret_cast(header.data()), header.size(), + ASYNC_WRITE_FLAG_COPY | ASYNC_WRITE_FLAG_MORE); + this->client_->add(reinterpret_cast(buffer.get_buffer()->data()), buffer.get_buffer()->size(), + ASYNC_WRITE_FLAG_COPY); bool ret = this->client_->send(); return ret; }