當在模擬器中本地運行時,web worker工作正常。但是每當我更新了Azure的VM上運行我的網絡工作者我得到在事件查看器和作用,但下列情況除外例外不會啓動:無法啓動Azure工作者角色,異常代碼0xe0434352&0xC0000035
Application: WaWorkerHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AggregateException
Stack: at System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken) at System.Threading.Tasks.Task.Wait()
at Foo.PushProcess.WorkerRole.Run()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal() at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b__2() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()Inner Exception: A task was canceled.
Faulting application name: WaWorkerHost.exe, version: 2.6.1198.712, time stamp: 0x54eba731
Faulting module name: KERNELBASE.dll, version: 6.3.9600.17415, time stamp: 0x54505737
Exception code: 0xe0434352
Fault offset: 0x0000000000008b9c
Faulting process id: 0xfb8
Faulting application start time: 0x01d11e3128981a5d
Faulting application path: E:\base\x64\WaWorkerHost.exe
Faulting module path: D:\Windows\system32\KERNELBASE.dll
Report Id: 30631c5c-8a25-11e5-80c6-000d3a22f3ec
Faulting package full name:
Faulting package-relative application ID:
Session "MA_ETWSESSION_WAD_415df88f8a0447178dbd4c18f1349f0e_Foo.PushProcess_Foo.PushProcess_IN_0" failed to start with the following error: 0xC0000035
這是相關代碼:
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
_storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
var queueClient = _storageAccount.CreateCloudQueueClient();
_pushQueue = queueClient.GetQueueReference("pushes");
_pushQueue.CreateIfNotExists();
CreatePushBroker();
Trace.TraceInformation("Foo.PushProcess has been started");
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
CloudQueueMessage message = null;
try
{
message = _pushQueue.GetMessage();
if (message != null)
{
ProcessItem(message);
}
}
catch (Exception ex)
{
if (message != null && message.DequeueCount > 5)
_pushQueue.DeleteMessage(message);
Trace.TraceError("[WORKER] Retrieval Failure: " + ex);
}
await Task.Delay(1000, cancellationToken);
}
}
注意一些代碼已被省略,但是這些代碼都是在初始化之後運行的,理論上這個異常沒有達到。
我完全不知道是什麼原因導致此問題。任何幫助將不勝感激 - 即使只是爲了幫助我得到一個有用的例外。
UPDATE
我現在已經減少了我的代碼以下 - 這是作爲一個網絡工作者都不可能是簡單 - 和我仍然得到例外。我相信無論是老員工都被緩存,還是在部署過程中都有問題。
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
// code removed for testing - no work is being done.
await Task.Delay(1000, cancellationToken);
}
}
嘗試發送鳴叫一個鏈接到這個問題@AzureSupport –
@StenPetrov感謝的是,我現在就發送。 –
現在解決了這個問題 - 我只是刪除了運行這個輔助角色的原始虛擬機,並創建了一個新的虛擬機。代碼然後在新的遠程機器上運行,沒有任何錯誤。不幸的是,我無法解釋爲什麼。 –