我正在尝试向我的 GCP IoT 设备发送新配置。Base64 编码的二进制字符串的长度约为 15k 字节。根据文档,GCP IoT 设备配置大小限制为 64k 。但我仍然收到 413(请求实体太大)错误。我究竟做错了什么?15k 似乎非常小,会产生这样的错误。谢谢你的帮助。
这是发送配置数据的 JavaScript 代码:
sendDeviceConfig(deviceId, configPayload) {
const parentName = `projects/${this.projectId}/locations/${this.cloudRegion}`;
const registryName = `${parentName}/registries/${this.registryId}`;
const binaryData = Buffer.from(configPayload).toString('base64');
const request = {
name: `${registryName}/devices/${deviceId}`,
versionToUpdate: 0,
binaryData: binaryData,
};
return new Promise((resolve, reject)=>{
this.client.projects.locations.registries.devices.modifyCloudToDeviceConfig(
request,
(err) => {
if (err) {
this.logger.error('Could not update config:', deviceId);
reject(err);
} else {
resolve();
}
}
);
});
}
...以及部分 HTML 格式(wtf?)错误响应:
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 413 (Request Entity Too Large)!!1</title>
...
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>413.</b> <ins>That’s an error.</ins>
<p>Your client issued a request that was too large.