WebJob occasionally throwing System.Threading.Tasks.TaskCanceledException - c#

I have a continuous WebJob which executes a function which is queue triggered and it occasionally throws System.Threading.Tasks.TaskCanceledException.
WebJobs SDK version : 2.1.0
StackTrace:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.ProcessCreationQueueMessage --->
System.AggregateException : One or more errors occurred. ---> A task was canceled. at
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at
System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at
Normandy.Portal.Reporting.Creation.WebJobs.Functions.ProcessCreationQueueMessage(String message,String& outputQueueMessage,TextWriter log) at
D:\a\1\s\Portal\src\Normandy.Portal.Reporting.Creation.WebJobs\Functions.cs : 105 at lambda_method(Closure ,Functions ,Object[] ) at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker`2.InvokeAsync(TReflected instance,Object[] arguments) at
async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) at
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) ---> (Inner Exception #0) System.Threading.Tasks.TaskCanceledException : A task was canceled.<--- End of inner exception
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)
WebJob:
public void ProcessCreationQueueMessage([QueueTrigger("reportcreation")] string message, [Queue("reportretrieval")] out string outputQueueMessage, TextWriter log)
{
JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
log.WriteLine(message);
...
try
{
var jobId = _reportingService.RequestReport(req.ReportName, searchString).Result;
var output = new RetrieveReportDataRequest()
{
CreationRequest = new ReportCreationRequest()
{
UserId = req.UserId,
UID = req.UID,
CreateDate = req.CreateDate,
IsMultiSchoolUser = req.IsMultiSchoolUser,
CentreCode = req.CentreCode,
ReportName = req.ReportName,
InputSearchParameters = req.InputSearchParameters,
},
SplunkSearchParameters = searchString,
SplunkJobId = jobId,
Created = DateTime.UtcNow,
};
outputQueueMessage = JsonConvert.SerializeObject(output, settings);
}
catch (Exception ex)
{
log.WriteLine(ex.Message);
throw;
}
}
There is no any time taking tasks apparently. This is failing once for certain messages. What am I missing?

It can be related to host-settings - look at Azure Portal -> AppService configuration, make sure that Always On is set to On:

Related

Invalid NEST response built from a unsuccessful () low level call on POST: when trying to run a console app in C#

I am new to elastic search. I am trying to use the code to search text. getting the Error "{Invalid NEST response built from a unsuccessful () low level call on POST: /foo/_doc}" when trying to run the code. I think I am missing something how to use Nest nuGet any help is welcome
using IdentityServer4.Models;
using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Net.Mime.MediaTypeNames;
class Program
{
static void Main(string[] args)
{
var settings = new ConnectionSettings(new Uri("http://127.0.0.1:9200"))
.DefaultIndex("foo");
var client = new ElasticClient(settings);
var indexName = "indexName";
if (client.IndexExists(indexName).Exists)
{
client.DeleteIndex(indexName);
}
var createIndexResponse = client.CreateIndex(indexName, c => c
.Settings(s => s
.Analysis(a => a
.Analyzers(an => an
.Custom("my_analyzer", ca => ca
.Tokenizer("standard")
.CharFilters("html_strip")
.Filters("lowercase")
)
)
)
)
.Mappings(m => m
.Map<Document>(mp => mp
.AutoMap()
.Properties(p => p
.Text(t => t
.Name(n => n.Title)
.Analyzer("my_analyzer")
)
.Text(t => t
.Name(n => n.Content)
.Analyzer("my_analyzer")
)
)
)
)
);
var doc = new Document
{
Title = "Friends are friendlier friendlies that are friendly and classify the friendly classification class.",
// Remove stop word like are, and, that,the
Content = "Flowery flowers flow through following the flower flows."
};
var indexResponse = client.IndexDocument(doc);
// Error occurred here
Console.WriteLine(indexResponse.Result);
Console.ReadKey();
}
}
Document class
class Document
{
public string Title { get; set; }
public string Content { get; set; }
}
Debugging Information
"Invalid NEST response built from a unsuccessful () low level call on PUT: /indexName\r\n# Audit trail of this API call:\r\n - [1] ProductCheckOnStartup: Took: 00:00:02.0264861\r\n - [2] ProductCheckFailure: Node: http://127.0.0.1:9200/ Took: 00:00:02.0261849\r\n# OriginalException: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET /\r\n ---> Elasticsearch.Net.PipelineException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product.\r\n ---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it.\r\n ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.\r\n at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\r\n --- End of inner exception stack trace ---\r\n at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)\r\n at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData)\r\n --- End of inner exception stack trace ---\r\n at Elasticsearch.Net.RequestPipeline.ThrowIfTransientProductCheckFailure()\r\n at Elasticsearch.Net.RequestPipeline.Ping(Node node)\r\n at Elasticsearch.Net.Transport1.Ping(IRequestPipeline pipeline, Node node)\r\n at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)\r\n --- End of inner exception stack trace ---\r\n# Request:\r\n<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>\r\n# Response:\r\n<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>\r\n"

Azure.WebJobs.Host.FunctionInvocationException when executing new job

I've added a new function to an already working WebJob. It gets triggered correctly and picked up from the queue, but throws an exception when its run.
There are unit tests for the function and it works as intended.
The WebJob runs 7 other functions successfully.
Here's what I've done:
Wrote the message that gets put on the queue
Wrote the function to get called
Added triggers to queue the message
Registered the function in the WebJob to respond to the message(s)
Fetching from queue
public async Task CheckPeripheralsWebJobAsync([QueueTrigger("%" + nameof(CheckPeripheralsWebJobMessage) + "%")] CheckPeripheralsWebJobMessage message)
{
var cloudQueue = GetQueue(message.unitId);
var idsToProcess = new List<int> { message.unitId };
if (await cloudQueue.PeekMessageAsync() != null)
{
foreach (var messageInQueue in await cloudQueue.GetMessagesAsync(32))
{
try
{
// Try to remove message
await cloudQueue.DeleteMessageAsync(messageInQueue);
int id;
var successfulParse = Int32.TryParse(messageInQueue.AsString, out id);
if (successfulParse)
{
idsToProcess.Add(id);
}
}
catch (Exception)
{
// This has been deleted already by another job, so do not process this one
}
}
}
await RunJob(idsToProcess); // This is the actual function
}
Program.cs
var config = new JobHostConfiguration
{
...
...
...
TypeLocator = new WebJobTypeLocator(
...
...
...
typeof(CheckPeripheralsWebJob) // %checkperipheralswebjobmessage%
)
};
Error message in console application
Executed 'CheckPeripheralsWebJob.CheckPeripheralsWebJobAsync' (Failed, Id=c5f2444f-0fda-4e94-aae7-e47d835ff3b4)
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: CheckPeripheralsWebJob.CheckPeripheralsWebJobAsync ---> Microsoft.WindowsAzure.Storage.StorageException : The remote server returned an error: (404) Not Found. ---> System.Net.WebException : The remote server returned an error: (404) Not Found.
at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode,HttpStatusCode actualStatusCode,T retVal,StorageCommandBase`1 cmd,Exception ex) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.cs : 50
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.<PeekMessagesImpl>b__45(RESTCommand`1 cmd,HttpWebResponse resp,Exception ex,OperationContext ctx) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Queue\CloudQueue.cs : 2700
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs : 299
End of inner exception
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs : 50
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.EndPeekMessage(IAsyncResult asyncResult) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Queue\CloudQueue.cs : 2165
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass2`1.<CreateCallback>b__0(IAsyncResult ar) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs : 69
at async ManagementPlatform.Services.UnitDiagnostics.CheckPeripheralsWebJob.CheckPeripheralsWebJobAsync(CheckPeripheralsWebJobMessage message) at C:\Projekt\25_Server\Code\Services\UnitDiagnostics\CheckPeripheralsWebJob.cs : 53
at async Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
End of inner exception
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)
Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is 'c5f2444f-0fda-4e94-aae7-e47d835ff3b4'
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: CheckPeripheralsWebJob.CheckPeripheralsWebJobAsync ---> Microsoft.WindowsAzure.Storage.StorageException : The remote server returned an error: (404) Not Found. ---> System.Net.WebException : The remote server returned an error: (404) Not Found.
at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode,HttpStatusCode actualStatusCode,T retVal,StorageCommandBase`1 cmd,Exception ex) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.cs : 50
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.<PeekMessagesImpl>b__45(RESTCommand`1 cmd,HttpWebResponse resp,Exception ex,OperationContext ctx) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Queue\CloudQueue.cs : 2700
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs : 299
End of inner exception
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs : 50
at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.EndPeekMessage(IAsyncResult asyncResult) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Queue\CloudQueue.cs : 2165
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass2`1.<CreateCallback>b__0(IAsyncResult ar) at c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs : 69
at async ManagementPlatform.Services.UnitDiagnostics.CheckPeripheralsWebJob.CheckPeripheralsWebJobAsync(CheckPeripheralsWebJobMessage message) at C:\Projekt\25_Server\Code\Services\UnitDiagnostics\CheckPeripheralsWebJob.cs : 53
at async Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
End of inner exception
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)
#davidg you were right, thank you.
"Possibly when you are peeking at the message"
The job was looking for a message object, but I was sending message.unitId to my lookup.

Google.Apis.Auth.OAuth2.Responses.TokenResponseException: invalid_grant, Robot is disabled

I am using Visual Studio for Mac for a .NET Console C# project using Google Speech API.
I am getting an error that says:
Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin. Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"invalid_grant", Description:"Robot is disabled.", Uri:""
at Google.Apis.Auth.OAuth2.Requests.TokenRequestExtenstions.ExecuteAsync(TokenRequest request, HttpClient httpClient, String tokenServerUrl, CancellationToken taskCancellationToken, IClock clock) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\Requests\TokenRequestExtenstions.cs:line 52
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.RequestAccessTokenAsync(CancellationToken taskCancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\ServiceAccountCredential.cs:line 212
at Google.Apis.Auth.OAuth2.TokenRefreshManager.RefreshTokenAsync() in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 129
at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 114
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.GetAccessTokenForRequestAsync(String authUri, CancellationToken cancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\ServiceAccountCredential.cs:line 235
at Grpc.Auth.GoogleAuthInterceptors.<>c__DisplayClass2_0.<<FromCredential>b__0>d.MoveNext() in T:\src\github\grpc\src\csharp\Grpc.Auth\GoogleAuthInterceptors.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
at Grpc.Core.Internal.NativeMetadataCredentialsPlugin.GetMetadataAsync(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeMetadataCredentialsPlugin.cs:line 83")'
at the line I mark with the comment "// error here" in the code:
class Program
{
static void Main(string[] args)
{
var URI = "https://speech.googleapis.com/v1/speech:recognize?key=[API_KEY]";
Console.WriteLine("Start!");
AsyncRecognizeGcs(URI);
Console.WriteLine("End.");
}
static object AsyncRecognizeGcs(string storageUri)
{
var speech = SpeechClient.Create();
var longOperation = speech.LongRunningRecognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
SampleRateHertz = 44100,
AudioChannelCount = 2,
LanguageCode = "en",
}, RecognitionAudio.FromStorageUri(storageUri)); // error here
longOperation = longOperation.PollUntilCompleted();
var response = longOperation.Result;
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine($"Transcript: { alternative.Transcript}");
}
}
return 0;
}
}
How do I fix this? Is there something else I need to set up with Google?
Recommend updating to a new version of Google.Cloud.PubSub.V1, which will pull in a newer version of Grpc.Core.
Use the last update of Google.Apis.Auth.
It turns out that I had the wrong credentials json file. Stupid mistake.

Azure Service Bus: AMQP object is closing. Operation 'attach' cannot be performed

I'm using Azure Service Bus Topics with the AMQP protocol in the West Europe datacenter.
This is a schematic way of how the solution implented works:
private Microsoft.Azure.ServiceBus.SubscriptionClient CreateClient() {
string serviceBusConnectionString;
strin serviceBusTopicName;
string subscriptionName;
var subscriptionClient = new Microsoft.Azure.ServiceBus.SubscriptionClient(serviceBusConnectionString, serviceBusTopicName, subscriptionName) {
PrefetchCount = 0
};
return subscriptionClient;
}
public async Task<ISubscriptionClient> CreateSubscriptionClientAsync() {
//Some logic on the subscriptionClient, caching, creating a new one if it doesn't exists, etc.
return CreateClient()
}
private async Task CallbackAsync(Message msg, CancellationToken cancellationToken) {
//Do stuff with the Message
//when you're done Completethe message
}
public async Task<string> OpenAsync(CancellationToken cancellationToken) {
subscriptionClient = await CreateSubscriptionClientAsync().ConfigureAwait(false);
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandlerAsync) {
AutoComplete = false,
MaxAutoRenewDuration = TimeSpan.FromHours(8)
};
subscriptionClient.RegisterMessageHandler(CallbackAsync, messageHandlerOptions);
return string.Empty;
}
But last night I had couple of thousand exception like this one:
Exception: "System.InvalidOperationException: The AMQP object g2b-sessionXXXXXXXX is closing. Operation 'attach' cannot be performed.
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<OnReceiveAsync>d__86.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass64_0.<<ReceiveAsync>b__0>d.MoveNext()
I'm using the Microsoft.Azure.ServiceBus v3.1.0.0,
On line I didn't find anything useful about this "Operation 'attach' cannot be performed".
On the message bus exception list page I didn't find any information about this specific problem. And in the status history site there is no reference about any outage involving Service Bus.
Did anyone experience this problem before?
What is causing the exception?
Do I need to implement any retry logic? How?
Any help is apreciated, thanks.

Mono The task has not finished yet

Using Task, await or Task.WhenAll always return System.InvalidOperationException The task has not finished yet
I tested the same application in Windows and all runs ok.
Another problem I found is "cannot return void" when I used:
Task<T> exampleTask = Task<T>(()=> { code; });
But in Windows using .Net Framework doesn't happen
I tested it in Ubuntu 12 and OpenSuse 12 with Mono 3 installed and .Net Framework 4.5 as the target to build.
The same code in Windows runs.
The Code
public async Task<ViewResult> Rss()
{
var client = new HttpClient();
var step1 = await client.GetStringAsync("https://github.com/mono/mono/commits/master.atom");
var step2 = await client.GetStringAsync("https://aspnetwebstack.codeplex.com/project/feeds/rss");
var step3 = await client.GetStringAsync("https://orchard.codeplex.com/project/feeds/rss");
ViewBag.MonoActivity = GetItems(step1);
ViewBag.MVC4Activity= GetItems(step2);
ViewBag.OrchardActivity= GetItems(step3);
return View();
}
public IList<SyndicationItem> GetItems(String xml)
{
var textReader = new StringReader(xml);
var xmlReader = XmlReader.Create(textReader);
var feed = SyndicationFeed.Load(xmlReader);
return feed == null ? null : new List<SyndicationItem>(feed.Items);
}
The Stack Trace
System.InvalidOperationException
The task has not finished yet
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000b] in
/home/abuild/rpmbuild/BUILD/mono-3.0.4/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00021]
in
/home/abuild/rpmbuild/BUILD/mono-3.0.4/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter.cs:57 at (wrapper dynamic-method) object.lambda_method
(System.Runtime.CompilerServices.Closure,System.Threading.Tasks.Task)
at
System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted
(System.Threading.Tasks.Task) at
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute
(System.IAsyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c_DisplayClass21.b_20
(System.IAsyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper/WrappedAsyncResult`1.End
() <0x00103> at
System.Web.Mvc.Async.AsyncResultWrapper.End
(System.IAsyncResult,object) <0x00073> at
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod
(System.IAsyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c_DisplayClass19/<>c_DisplayClass1b.b_15
() at
System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c_DisplayClass31.b__2b
()

Categories

Resources