Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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. #3764

Closed
2 tasks
dimalama opened this issue Jun 13, 2019 · 17 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Milestone

Comments

@dimalama
Copy link

  • @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:

  1. Create topic in service bus
  2. Create subscription to the topic
  3. 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);
});
  1. Execute code

Expected behavior
Process and clear up messages inside the topic without error.

Screenshots
Receive message from topic inside onMessageHandler:
image

When onMessageHandler is done executing:
image

Error:
image

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
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 13, 2019

Thanks for reporting @dlukianenko

When a request to settle a message (in your case "complete" a message) is made to Service Bus, the library waits for 20 seconds to hear back an acknowledgement that the message has indeed been successfully settled. The error you are seeing is thrown when this 20 second duration times out.

@binzywu What should be the ideal timeout duration for this case i.e. how long should the client library wait to hear back an acknowledgement from the service? Can you think of any reason why the service would fail to respond within the 20 sec timeframe?

@ramya-rao-a ramya-rao-a added Service Attention This issue is responsible by Azure service team. Service Bus labels Jun 13, 2019
@jfggdl jfggdl added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Jun 13, 2019
@jfggdl
Copy link

jfggdl commented Jun 19, 2019

@dlukianenko, would you please create a support request from the Azure Portal for this issue and include in it more contextual information like the name of your namespace? This is an issue for which we need to do further investigation on the service side. 20 seconds timeout should be enough and the fact that you are getting an error may be indicative of some other problem condition.

I am going to close this issue, but feel free to reopen it if you have other kind of questions.

@jfggdl jfggdl closed this as completed Jun 19, 2019
@jfggdl jfggdl modified the milestones: Sprint 155, Sprint 154 Jul 25, 2019
@jfggdl
Copy link

jfggdl commented Jul 26, 2019

@dlukianenko

@jfggdl jfggdl reopened this Jul 26, 2019
@jfggdl
Copy link

jfggdl commented Jul 26, 2019

@dlukianenko, did you create the support request? Would you please share the SR#?

@dimalama
Copy link
Author

Hello, I'm on a dev-test subscription and currently, I don't have a tech support subscription, so I cannot really create actual ServiceBus support requests without paying for tech support subscription. Is there any other option available to me?

@ramya-rao-a ramya-rao-a added customer-reported Issues that are reported by GitHub users external to the Azure organization. and removed customer-response-expected labels Jul 30, 2019
@AlexGhiondea AlexGhiondea modified the milestones: Sprint 154, Sprint 157 Aug 13, 2019
@SamJarmanPP
Copy link

We've also seen this over 1500 times since our service using service into production a few months ago. Are there any queue configurations to check or anything we can do before raising a support query? Thanks @ramya-rao-a :)

@SamJarmanPP
Copy link

As a work around, would it make sense to check message.isSettled before processing? Does that get successfully written in the case of these timeouts?

@ramya-rao-a
Copy link
Contributor

@SamJarmanPP Unfortunately no. he isSettled property on a message gets set on the service side before it sends the message to the client. Once the client makes the request to settle the message, the client then waits for an acknowledgement from the service. This is where the time out happens. The message object is entirely on the client side at this point and is not mutated.

@SamJarmanPP
Copy link

@ramya-rao-a Ah okay, darn. I asked over here what we should do in these cases - looking forward to hearing back :) We just want to make sure the message is processed once and only once, and that this is guaranteed. (Are we asking too much? haha)

@AlexGhiondea AlexGhiondea added the Client This issue points to a problem in the data-plane of the library. label Aug 14, 2019
@binzywu
Copy link
Contributor

binzywu commented Aug 14, 2019

@SamJarmanPP please could you open a support case and provide us more details of namespace, entity, timestamp and ideally few sample message ids will be very helpful.

@SamJarmanPP
Copy link

@binzywu Sure but I feel the answer you provide would be applicable to anyone receiving this error?

@ramya-rao-a
Copy link
Contributor

@SamJarmanPP Opening a support case/ticket will help @binzywu's team investigate the problem because they can then check the logs from the service side as well. Once they come to a conclusion on what the problem is, @binzywu or his team will surely update this GitHub issue with the answer and possible steps that can be taken to fix it

@SamJarmanPP
Copy link

@binzywu @ramya-rao-a opened one yesterday - 119081423002394 :)

@axisc
Copy link

axisc commented Aug 16, 2019

Thanks @SamJarmanPP,

I'll close the issue now and we can track this via the support ticket.

@axisc axisc closed this as completed Aug 16, 2019
@ramya-rao-a
Copy link
Contributor

@axayjo Based on the support ticket logged by @SamJarmanPP, his issue is with what is being discussed at #2828 (comment)

Originally, this issue was logged by @dlukianenko who doesn't have a subscription with tech support. Can you suggest any other way you can look into why the service is not able to settle messages within 20 seconds?

@ramya-rao-a ramya-rao-a reopened this Aug 16, 2019
@axisc axisc removed the Service Attention This issue is responsible by Azure service team. label Aug 23, 2019
@axisc
Copy link

axisc commented Aug 23, 2019

@dlukianenko

We will need to access the service logs for the specified namespace to debug the root cause of the delay in completing the message.

In the meantime, there are some options

  • Increasing the operation timeout (in other lang clients, the default timeout is 60 seconds)
  • Rely on retry logic

I'm closing the issue for now. Please feel free to reopen if you still have questions.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 12, 2019

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

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

8 participants