question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequestClient receives TimeOutException instead of RequestFaultException

See original GitHub issue

Is this a bug report?

Update: I’m not sure

Can you also reproduce the problem with the latest version?

Yes

Environment

  1. Operating system: Windows 10
  2. Visual Studio version: Visual Studio 2017
  3. Dotnet version: .NET Framework 4.6.2

Steps to Reproduce

Given following Code:

using System;
using System.Security;
using System.Threading.Tasks;
using MassTransit;

namespace ConsoleApp4
{
    class Program
    {
        private static string QUEUE_NAME = "some.test.queue";

        static void Main(string[] args)
        {
            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://localhost:/"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                sbc.ReceiveEndpoint(host, QUEUE_NAME, endpoint =>
                {
                    endpoint.Consumer<MyMessageConsumer>();
                });
            });

            Task.WaitAll(bus.StartAsync());

            var requestClient = bus.CreateRequestClient<MyMessage, MyResponse>(new Uri($"rabbitmq://localhost:/{QUEUE_NAME}"), TimeSpan.FromSeconds(5));

            try
            {
                var result = requestClient.Request(new MyMessage {Value = "Hello, World."}).GetAwaiter().GetResult();
                Console.WriteLine("Got Result from Service: {0}", result.Value);
            }
            catch (Exception ex)
            {
                Console.WriteLine("got exception {0}", ex.GetType());
                // TimeOut-Exception instead of RequestFaultException?
            }
            
            Console.ReadLine();
            Task.WaitAll(bus.StopAsync());
        }
    }

    class MyMessageConsumer : IConsumer<MyMessage>
    {
        public Task Consume(ConsumeContext<MyMessage> context)
        {
            // throw a readable exception, which the request-client should read
            throw new SecurityException("Client should please read this");
            
            // return context.RespondAsync(new MyResponse { Value = context.Message.Value });
        }
    }

    class MyMessage
    {
        public string Value { get; set; }
    }

    class MyResponse
    {
        public string Value { get; set; }
    }

}

Expected Behavior

The RequestClient should get a RequestFaultedException, with the actual exception in it.

Actual Behavior

A Timeout-Exception occurs instead of a RequestFaultedException

This worked in 3.5.7 before updating to 5.3.2 (i know, big step). We’re using the request-client on many, many places in our code and our GlobalExceptionHandler handled these RequestFaults before, and now it can’t because a timeoutexception occurs instead.

Update:: My sample throws a timeoutexception too, on version 3.5.7, so I’m not sure, whats happening…

Reproducible Demo

See Steps to Reproduce Issue https://github.com/MassTransit/MassTransit/issues/1006 seems to be identical.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
phatboygcommented, Mar 14, 2019

Yes, any blocking code in the async/TPL world causes random issues.

0reactions
bschaeublincommented, Mar 13, 2019

closing this, as it seems I fixed the issue at our code-base with refactoring the “async” code and removing all the blocking .result code.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

(Request/response) Request not receiving an exception ...
On the Request/Response ideia... I have a handler: public class AutenticacaoHandler : IConsumer { public async Task Consume(ConsumeContext ...
Read more >
How to catch timeout exception in Spring WebClient?
1 Answer. From java doc: Switch to a fallback Mono in case no item arrives within the given Duration. If the fallback Mono...
Read more >
How to Avoid java.util.concurrent. TimeoutException
The java.util.concurrent.TimeoutException is thrown when a blocking operation times out. Learn how to avoid it.
Read more >
TimeoutException (Java Platform SE 8 )
Exception thrown when a blocking operation times out. Blocking operations for which a timeout is specified need a means to indicate that the...
Read more >
TimeoutException Class (System)
Initializes a new instance of the TimeoutException class with the specified error message and inner exception. Properties. Data. Gets a collection of key/value ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found