I have a Node-RED installation running with the BigQuery node that all of a sudden stopped working. Have been able to narrow it down to a very small example which I can't get to work anymore:
我有一个使用BigQuery节点运行的节点红色安装,该节点突然停止工作。我可以把它缩小到一个很小的例子我不能再继续工作了
The code looks like this:
代码是这样的:
// Imports the Google Cloud client library
const BigQuery = require('@google-cloud/bigquery');
// Your Google Cloud Platform project ID
const projectId = 'my-project';
const file = './google-cloud-auth.json'
// Creates a client
const bigquery = new BigQuery({
projectId: projectId,
keyFilename: file
});
const datainsert = {
"water_total": 555,
"power_vp": 3460651,
"power_ftx": 4401819,
"time": "2018-01-23T09:50:17.672Z",
"power_total": 5737457,
"power_garage_radiator_south": 182521,
"power_garage_radiator_north": 76388
};
// The name for the new dataset
const dataset = bigquery.dataset('consumption');
const table = dataset.table('consumption_test');
table.insert(datainsert, function(err, response) {
console.log(JSON.stringify(err));
console.log(JSON.stringify(response));
});
When I run this on my Ubuntu machine (NodeJS v4.8.7) it outputs:
当我在我的Ubuntu机器上运行这个(NodeJS v4.8.7)时,它会输出:
{}
undefined
and nothing gets written to BQ. However, when I run the exact same code (in fact I have tried to copy the entire folder structure) on my Mac (NodeJS v6.9.4) it outputs:
没有写到BQ。然而,当我运行完全相同的代码时(实际上,我试图复制整个文件夹结构)在我的Mac上(NodeJS v6.9.4),它输出:
null
{"kind":"bigquery#tableDataInsertAllResponse"}
and the record is stored successfully.
记录被成功存储。
Obviously I thought it was related to the Node version so I tried running it in the very Docker container it used to run but with NodeJS v6.9.4 but it still doesn't run successfully on that machine. I'm running with the same authentication file so I don't think it's related to that.
显然,我认为它与节点版本有关,所以我尝试在Docker容器中运行它,但是使用NodeJS v6.9.4,它仍然不能在机器上成功运行。我使用相同的身份验证文件运行,所以我不认为它与此相关。
Would anyone happen to know what it is within my environment that causing this to happen?
有人知道是什么在我的环境中导致了这一切吗?
1 个解决方案
#1
3
After several hours of head scratching I finally found the problem to be clock slightly out of sync on the machine (5 minutes). I realized this when I decided to run other commands to see if they worked. When trying to get a list of datasets I got the following (quite helpful) error back:
经过几个小时的挠头之后,我终于发现机器上的时钟有点不同步(5分钟)。当我决定运行其他命令以查看它们是否有效时,我意识到了这一点。当我试图获取数据集列表时,我得到了以下(非常有用的)错误:
[Error: invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.]
[错误:invalid_grant: Invalid JWT: Token必须是一个短命的令牌(60分钟),并且在合理的时间范围内。检查您的iat和exp值,并使用带有倾斜的时钟来解释系统之间的时钟差异。
Problem solved.
问题解决了。
#1
3
After several hours of head scratching I finally found the problem to be clock slightly out of sync on the machine (5 minutes). I realized this when I decided to run other commands to see if they worked. When trying to get a list of datasets I got the following (quite helpful) error back:
经过几个小时的挠头之后,我终于发现机器上的时钟有点不同步(5分钟)。当我决定运行其他命令以查看它们是否有效时,我意识到了这一点。当我试图获取数据集列表时,我得到了以下(非常有用的)错误:
[Error: invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.]
[错误:invalid_grant: Invalid JWT: Token必须是一个短命的令牌(60分钟),并且在合理的时间范围内。检查您的iat和exp值,并使用带有倾斜的时钟来解释系统之间的时钟差异。
Problem solved.
问题解决了。