Azure ServiceBus Token Expired

我只是一个虾纸丫 提交于 2020-01-04 13:25:12

问题


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

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

There is only one Shared Access Policy 'RootManageSharedAccessKey' with permissions to 'Manage, Send, Listen'

What could be wrong in this?


回答1:


OK, this problem comes when the time on the machine is older than the current time.

Fix:

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

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 )&

That should update the time on boot and then the Azure error on expired token will not be thrown



来源:https://stackoverflow.com/questions/29516009/azure-servicebus-token-expired

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!