2

我正在使用 NodeJS 访问 Azure ServiceBus,它运行了好几天。突然间,我开始收到一个错误

Subscription Deletion Error :Error: 401 - ExpiredToken: . TrackingId:xxxxxx-xxxxxxx,TimeStamp:4/8/2015 12:32:54 PM

我正在使用连接字符串连接到 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”具有“管理、发送、收听”权限

这有什么问题?

4

1 回答 1

3

好的,当机器上的时间早于当前时间时,就会出现这个问题。

使固定:

sudo service ntp stop sudo ntpdate -s time.nist.gov sudo service ntp start

如果你想把它放在 /etc/rc.local 中,请使用以下命令:

( /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 错误

于 2015-04-12T03:41:05.130 回答