Azure ServiceBus令牌已过期 [英] Azure ServiceBus Token Expired
问题描述
我正在使用NodeJS访问Azure ServiceBus,并且工作了好几天.突然,我开始收到错误消息
I am accessing Azure ServiceBus using NodeJS and it worked fine for several days. All of a sudden, I started receiving an error
Subscription Deletion Error :Error: 401 - ExpiredToken: . TrackingId:xxxxxx-xxxxxxx,TimeStamp:4/8/2015 12:32:54 PM
Subscription Deletion Error :Error: 401 - ExpiredToken: . TrackingId:xxxxxx-xxxxxxx,TimeStamp:4/8/2015 12:32:54 PM
我正在使用连接字符串连接到ServiceBus
I am using the connection string to connect to ServiceBus
var azure = require('azure');
var serviceBusConnectionString = "Endpoint=sb://somens.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=mykey";
var serviceBusService = azure.createServiceBusService(serviceBusConnectionString);
var rule = {
deleteDefault: function () {
serviceBusService.deleteRule(topicName,
subscriptionName,
azure.Constants.ServiceBusConstants.DEFAULT_RULE_NAME,
rule.handleError);
},
create: function () {
var ruleOptions = {
sqlExpressionFilter: subscriptionCriteria
};
rule.deleteDefault();
serviceBusService.createRule(topicName,
subscriptionName,
filterName,
ruleOptions,
rule.handleError);
},
handleError: function (error) {
if (error) {
console.log(error);
}
}
} //rule
serviceBusService.deleteSubscription(topicName, subscriptionName, function (error) {
if (error) {
console.log("Subscription Deletion Error :" + error);
createMessageSubscription();
}
else {
console.log('Subscription deleted : ' + subscriptionName);
createMessageSubscription();
}
}); //deleteSubscription
只有一个共享访问策略"RootManageSharedAccessKey"具有管理,发送,侦听"权限
There is only one Shared Access Policy 'RootManageSharedAccessKey' with permissions to 'Manage, Send, Listen'
这可能是什么问题?
推荐答案
好的,当计算机上的时间早于当前时间时,就会出现此问题.
OK, this problem comes when the time on the machine is older than the current time.
修复:
sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start
sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start
如果要将其放在/etc/rc.local中,请使用以下命令:
If you want to put this in /etc/rc.local use the following:
( /etc/init.d/ntp stop
until ping -nq -c3 8.8.8.8; do
echo "Waiting for network..."
done
ntpdate -s time.nist.gov
/etc/init.d/ntp start )&
( /etc/init.d/ntp stop
until ping -nq -c3 8.8.8.8; do
echo "Waiting for network..."
done
ntpdate -s time.nist.gov
/etc/init.d/ntp start )&
那应该会更新启动时间,然后不会抛出过期令牌上的Azure错误
That should update the time on boot and then the Azure error on expired token will not be thrown
这篇关于Azure ServiceBus令牌已过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!