azure-sdk-for-js: [Service Bus] The code always throws error "Operation to settle the message has timed out. The disposition of the message may or may not be successful" after processing message.
- @azure/service-bus:
- 1.0.2:
- Mac OS:
- nodejs
- 11.2.0:
- typescript
- 3.5.1:
The error “Operation to settle the message has timed out. The disposition of the message may or may not be successful” happens every time during message processing I have created topic inside AzurePortal => Service Bus and created subscription to that topic. I copied the example from documentation.
const { ServiceBusClient, ReceiveMode, delay } = require('@azure/service-bus');
export class SubscriptionService {
constructor() {
this.main().catch((err) => {
console.log('Error occurred: ', err);
});
private async main() {
const sbClient = ServiceBusClient.createFromConnectionString(process.env.AZURE_SERVICEBUS_CONNECTION_STRING || '');
// If receiving from a Subscription, use `createSubscriptionClient` instead of `createQueueClient`
const queueClient = sbClient.createSubscriptionClient(TestTopic, 'test');
// To receive messages from sessions, use getSessionReceiver instead of getReceiver or look at
// the sample in sessions.js file
const receiver = queueClient.createReceiver(ReceiveMode.peekLock);
const onMessageHandler = async (brokeredMessage: any) => {
console.log(`Received message: ${brokeredMessage.body}`);
await brokeredMessage.complete();
};
const onErrorHandler = (err: any) => {
console.log("Error occurred: ", err);
};
try {
receiver.registerMessageHandler(onMessageHandler, onErrorHandler, { autoComplete: false });
// Waiting long enough before closing the receiver to receive messages
await delay(5000);
await receiver.close();
await queueClient.close();
} finally {
await sbClient.close();
}
}
}
onMessageHandler receives a message from the topic. The code processes the message. Message got removed from Azure Portal => Service Bus. I get the error Operation to settle the message has timed out. The disposition of the message may or may not be successful inside onErrorHandler after onMessageHandler is done executing. Error happens every time.
To Reproduce Steps to reproduce the behavior:
- Create topic in service bus
- Create subscription to the topic
- Use the code from documentation
const { ServiceBusClient, ReceiveMode, delay } = require("@azure/service-bus");
// Define connection string and related Service Bus entity names here
const connectionString = "";
const queueName = "";
async function main() {
const sbClient = ServiceBusClient.createFromConnectionString(connectionString);
// If receiving from a Subscription, use `createSubscriptionClient` instead of `createQueueClient`
const queueClient = sbClient.createQueueClient(queueName);
// To receive messages from sessions, use getSessionReceiver instead of getReceiver or look at
// the sample in sessions.js file
const receiver = queueClient.createReceiver(ReceiveMode.peekLock);
const onMessageHandler = async (brokeredMessage) => {
console.log(`Received message: ${brokeredMessage.body}`);
await brokeredMessage.complete();
};
const onErrorHandler = (err) => {
console.log("Error occurred: ", err);
};
try {
receiver.registerMessageHandler(onMessageHandler, onErrorHandler, { autoComplete: false });
// Waiting long enough before closing the receiver to receive messages
await delay(5000);
await receiver.close();
await queueClient.close();
} finally {
await sbClient.close();
}
}
main().catch((err) => {
console.log("Error occurred: ", err);
});
- Execute code
Expected behavior Process and clear up messages inside the topic without error.
Screenshots
Receive message from topic inside onMessageHandler:

When onMessageHandler is done executing:

Error:

Additional context Full error:
condition:"com.microsoft:timeout"
info:undefined
message:"Operation to settle the message has timed out. The disposition of the message may or may not be successful"
name:"ServiceUnavailableError"
retryable:true
stack:"ServiceUnavailableError: Operation to settle the message has timed out. The disposition of the message may or may not be successful\n at Object.translate (/Users/d/Projects/SB/node_modules/@azure/amqp-common/dist/index.js:741:17)\n at Timeout.setTimeout [as _onTimeout] (/Users/d/Projects/SB/node_modules/@azure/service-bus/dist/index.js:2317:46)\n at listOnTimeout (timers.js:324:15)\n at processTimers (timers.js:268:5)"
translated:true
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Increase timeout for settling msgs to 60sec #3764 — committed to ramya-rao-a/azure-sdk-for-js by ramya-rao-a 5 years ago
The latest version of the Service Bus library (1.0.4) has the timeout increased from 20 seconds to 60 seconds as suggested by @axisc
It also has the fix for the issue reported by @SamJarmanPP where messages failed to settle repeatedly after the library recovered from a broken receiver link