{"action":"closed","issue":{"url":"https://api.github.com/repos/MassTransit/MassTransit/issues/431","repository_url":"https://api.github.com/repos/MassTransit/MassTransit","labels_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/431/labels{/name}","comments_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/431/comments","events_url":"https://api.github.com/repos/MassTransit/MassTransit/issues/431/events","html_url":"https://github.com/MassTransit/MassTransit/issues/431","id":124417901,"number":431,"title":"Mass transit Endpoint.Send<>() with azure service bus throws (401) Unauthorized. InvalidAudience: The authorization header contains a token with a wrong audience. ","user":{"login":"auzebmanzoor","id":12646426,"avatar_url":"https://avatars.githubusercontent.com/u/12646426?v=3","gravatar_id":"","url":"https://api.github.com/users/auzebmanzoor","html_url":"https://github.com/auzebmanzoor","followers_url":"https://api.github.com/users/auzebmanzoor/followers","following_url":"https://api.github.com/users/auzebmanzoor/following{/other_user}","gists_url":"https://api.github.com/users/auzebmanzoor/gists{/gist_id}","starred_url":"https://api.github.com/users/auzebmanzoor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auzebmanzoor/subscriptions","organizations_url":"https://api.github.com/users/auzebmanzoor/orgs","repos_url":"https://api.github.com/users/auzebmanzoor/repos","events_url":"https://api.github.com/users/auzebmanzoor/events{/privacy}","received_events_url":"https://api.github.com/users/auzebmanzoor/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MassTransit/MassTransit/labels/servicebus","name":"servicebus","color":"bfd4f2"},{"url":"https://api.github.com/repos/MassTransit/MassTransit/labels/v2","name":"v2","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-31T00:33:53Z","updated_at":"2016-04-22T16:18:03Z","closed_at":"2016-04-22T16:18:03Z","body":"When using Mass transit on top of azure service bus to publish messages from ASP.net web API to the service bus I get the following error message when the API has been running a few days without being restarted:\r\n\r\nAt least one exception occurred publishing Application.Contract.Commands.SendEmailCommand to azure-sb://sbname/Application.Contract.Commands..SendEmailCommand?topic=true    at MassTransit.ServiceBus.Publish[T](T message, Action`1 contextCallback) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\ServiceBus.cs:line 207\r\n   at MassTransit.ServiceBus.Publish[T](T message) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\ServiceBus.cs:line 156\r\n   at Application.Tasks.EmailTask.CreateSendEmailCommand(EmailModel email) in C:\\ci\\BuildAgents\\buildAgent003\\work\\b188d2e91803c37c\\src\\app\\Application.Tasks\\EmailTask.cs:line 26\r\n   at Application.Services.MessagingService.<SendUserMessageAsync>d__7.MoveNext() in C:\\ci\\BuildAgents\\buildAgent003\\work\\b188d2e91803c37c\\src\\app\\Application\\Services\\MessagingService.cs:line 80\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at Application.Controllers.Api.MessageController.<Post>d__4.MoveNext() in C:\\ci\\BuildAgents\\buildAgent003\\work\\b188d2e91803c37c\\src\\app\\Application\\Controllers\\Api\\MessageController.cs:line 159\r\nazure-sb://sbname/Application.Contract.Commands..SendEmailCommand?topic=true => An exception was thrown during Send    at MassTransit.Transports.Endpoint.Send[T](ISendContext`1 context) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\Transports\\Endpoint.cs:line 117\r\n   at MassTransit.Pipeline.Sinks.EndpointMessageSink`1.<Enumerate>b__0(IBusPublishContext`1 x) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\Pipeline\\Sinks\\EndpointMessageSink.cs:line 45\r\n   at MassTransit.Pipeline.Sinks.OutboundConvertMessageSink`1.<>c__DisplayClass2.<>c__DisplayClass4.<Enumerate>b__1(ISendContext x) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\Pipeline\\Sinks\\OutboundConvertMessageSink.cs: line 36 \r\nat MassTransit.ServiceBus.Publish[T](T message, Action`1 contextCallback) in z:\\Builds\\work\\4ed32a1c3fc3f594\\src\\MassTransit\\ServiceBus.cs:line 180\r\n**The remote server returned an error: (401) Unauthorized. InvalidAudience: The authorization header contains a token with a wrong audience. TrackingId:2c588734-7891-45a5-a61e-430a88c00bc2_G35** TimeStamp:12/18/2015 3:57:18 PM \r\nServer stack trace:  \r\n\r\nCurrently the service bus and endpoint are configured with a Singleton lifestyle inside the IoC container. Is this because mass transit caches the access token for service bus which expires after some time? \r\n\r\nCurrently using the following version of MassTransit:\r\n\"MassTransit\" version=\"2.10.1\"\r\n\"MassTransit.AzureServiceBus\" version=\"0.4.1\" \r\n\r\nThanks!\r\n-Auzeb"}}