Azure/azure-iot-protocol-gateway

Fresh clone does not pass End2EndTests.BasicFunctionalityTest

Opened this issue · 0 comments

I've cloned the repository and followed the instructions to configure the environment to run the BasicFunctionalityTest. I'm using

  • Visual Studio 2017 15.7.5
  • Windows Azure Storage Emulator 5.4.0.0
  • Service Fabric SDK 3.2.162

After cloning the repository a rebuild all works.

I modified the appSettings.config.userwith the IoT Hub Connection string which I took the Shared Access device connection string and I also created a device before that and specified in this configuration.

While running the test from Test Explorer in Visual Studio 2017 (Pro) I receive the following error:

Test Name:	Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test FullName:	Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test Source:	D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs : line 181
Test Outcome:	Failed
Test Duration:	0:00:13,132

Result StackTrace:	
at Microsoft.Azure.Devices.HttpClientHelper.<ExecuteAsync>d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Devices.HttpClientHelper.<GetAsync>d__8`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.<BasicFunctionalityTest>d__26.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 212
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	Microsoft.Azure.Devices.Common.Exceptions.UnauthorizedException : {"Message":"ErrorCode:IotHubUnauthorizedAccess;Unauthorized","ExceptionMessage":"Tracking ID:378618db9ca44ba58e70f3f408225dc7-G:2-TimeStamp:08/03/2018 09:55:25"}
Result StandardOutput:	
EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.Logging.InternalLoggerFactory] [message : Using EventSource as the default logging framework] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:22.3413337Z, ProcessId : 14180, ThreadId : 892


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numHeapArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numDirectArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.pageSize: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxOrder: 11] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.chunkSize: 16777216] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.tinyCacheSize: 512] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.smallCacheSize: 256] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.normalCacheSize: 64] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxCachedBufferCapacity: 32768] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.cacheTrimInterval: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8573304Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.PlatformDependent] [message : -Dio.netty.noPreferDirect: False] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8583316Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.processId: 2265018 (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:23.8833334Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.machineId: 00:15:5D:FF:FE:00:A4:0C (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:24.1063328Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.ByteBufferUtil] [message : -Dio.netty.allocator.type: pooled] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:24.1083327Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.level: simple] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:24.1133328Z, ProcessId : 14180, ThreadId : 1716


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.targetRecords: 4] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T09:55:24.1133328Z, ProcessId : 14180, ThreadId : 1716


Server cleanup did not complete in time.

I changed after that the connection string to use the iothubowner Shared Connection String with all policies and receive now a different error

Test Name:	Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test FullName:	Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test Source:	D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs : line 181
Test Outcome:	Failed
Test Duration:	0:00:44,702

Result StackTrace:	
at Microsoft.Azure.Devices.ProtocolGateway.Tests.ReadListeningHandler.<ReceiveAsync>d__10.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\ReadListeningHandler.cs:line 82
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.ClientScenarios.<ConnectAsync>d__9.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 534
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.ClientScenarios.<RunPart1StepsAsync>d__4.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 426
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.ProtocolGateway.Tests.Extensions.TaskExtensions.<WithTimeoutInternal>d__1.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\Extensions\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.<BasicFunctionalityTest>d__26.MoveNext() in D:\src\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 276
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	System.TimeoutException : ReceiveAsync timed out
Result StandardOutput:	
EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.Logging.InternalLoggerFactory] [message : Using EventSource as the default logging framework] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:36.9028963Z, ProcessId : 17892, ThreadId : 18120


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numHeapArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6448952Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numDirectArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.pageSize: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxOrder: 11] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.chunkSize: 16777216] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.tinyCacheSize: 512] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.smallCacheSize: 256] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.normalCacheSize: 64] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxCachedBufferCapacity: 32768] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.cacheTrimInterval: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6458953Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.PlatformDependent] [message : -Dio.netty.noPreferDirect: False] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6469006Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.processId: 2218969 (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.6678966Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.machineId: 00:15:5D:FF:FE:00:A4:0C (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.9078979Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.ByteBufferUtil] [message : -Dio.netty.allocator.type: pooled] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.9088983Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.level: simple] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.9148968Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.targetRecords: 4] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:37.9148968Z, ProcessId : 17892, ThreadId : 18104


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f] REGISTERED] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.7639036Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f] CONNECT: 127.0.0.1:8883] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.7658945Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] ACTIVE] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.7768995Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : SERVER] [message : [id: 0x02469a74, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] REGISTERED] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.7878960Z, ProcessId : 17892, ThreadId : 18112


EventId : 2, Level : Verbose, Message : , Payload : [source : SERVER] [message : [id: 0x02469a74, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] ACTIVE] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.7878960Z, ProcessId : 17892, ThreadId : 18112


EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.AbstractByteBuffer] [message : -Dio.netty.buffer.bytebuf.checkAccessible: True] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.8008987Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] WRITE: ConnectPacket[Type=CONNECT, QualityOfService=AtMostOnce, Duplicate=False, Retain=False]] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.8348977Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] FLUSH] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.8658964Z, ProcessId : 17892, ThreadId : 17952


EventId : 2, Level : Verbose, Message : , Payload : [source : SERVER] [message : [id: 0x02469a74, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] USER_EVENT: TlsHandshakeCompletionEvent(SUCCESS)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.8828975Z, ProcessId : 17892, ThreadId : 18112


EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x45256f9f, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] USER_EVENT: TlsHandshakeCompletionEvent(SUCCESS)] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.9098938Z, ProcessId : 17892, ThreadId : 17952


User Event: TlsHandshakeCompletionEvent(SUCCESS)
EventId : 2, Level : Verbose, Message : , Payload : [source : SERVER] [message : [id: 0x02469a74, [::ffff:127.0.0.1]:59321 => [::ffff:127.0.0.1]:8883] RECEIVED: ConnectPacket[Type=CONNECT, QualityOfService=AtMostOnce, Duplicate=False, Retain=False]] [info : ] , EventName : DebugInfo, Timestamp : 2018-08-03T10:00:50.9198962Z, ProcessId : 17892, ThreadId : 18112


EventId : 4, Level : Warning, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelPipeline] [message : Failed to submit an ExceptionCaught() event.] [exception : System.TypeInitializationException: The type initializer for 'Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters' threw an exception. ---> System.Security.SecurityException: Requested registry access is not allowed.
   at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at System.Diagnostics.PerformanceCounterLib.CreateRegistryEntry(String categoryName, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection creationData, Boolean& iniRegistered)
   at System.Diagnostics.PerformanceCounterLib.RegisterCategory(String categoryName, PerformanceCounterCategoryType categoryType, String categoryHelp, CounterCreationDataCollection creationData)
   at System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData)
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.WindowsPerformanceCounterManager.GetOrCreateCounterCategory(PerformanceCounterCategoryInfo categoryInfo, CounterCreationData[] counters) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\WindowsPerformanceCounterManager.cs:line 58
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.WindowsPerformanceCounterManager..ctor(IDictionary`2 counterDefinitions) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\WindowsPerformanceCounterManager.cs:line 21
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters.Manager..ctor() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 73
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters.GetPerformanceCounterManager() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 65
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters..cctor() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 33
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Devices.ProtocolGateway.Mqtt.MqttAdapter.ShutdownOnError(IChannelHandlerContext context, String scope, Exception error) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Mqtt\MqttAdapter.cs:line 1010
   at Microsoft.Azure.Devices.ProtocolGateway.Mqtt.MqttAdapter.ExceptionCaught(IChannelHandlerContext context, Exception exception) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Mqtt\MqttAdapter.cs:line 194
   at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeExceptionCaught(Exception cause)] , EventName : WarningInfo, Timestamp : 2018-08-03T10:00:51.6959329Z, ProcessId : 17892, ThreadId : 18112


EventId : 4, Level : Warning, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelPipeline] [message : An exception was thrown by a user handler's ExceptionCaught() method while handling the following exception:] [exception : System.TypeInitializationException: The type initializer for 'Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters' threw an exception. ---> System.Security.SecurityException: Requested registry access is not allowed.
   at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at System.Diagnostics.PerformanceCounterLib.CreateRegistryEntry(String categoryName, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection creationData, Boolean& iniRegistered)
   at System.Diagnostics.PerformanceCounterLib.RegisterCategory(String categoryName, PerformanceCounterCategoryType categoryType, String categoryHelp, CounterCreationDataCollection creationData)
   at System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData)
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.WindowsPerformanceCounterManager.GetOrCreateCounterCategory(PerformanceCounterCategoryInfo categoryInfo, CounterCreationData[] counters) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\WindowsPerformanceCounterManager.cs:line 58
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.WindowsPerformanceCounterManager..ctor(IDictionary`2 counterDefinitions) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\WindowsPerformanceCounterManager.cs:line 21
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters.Manager..ctor() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 73
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters.GetPerformanceCounterManager() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 65
   at Microsoft.Azure.Devices.ProtocolGateway.Instrumentation.PerformanceCounters..cctor() in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Instrumentation\PerformanceCounters.cs:line 33
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Devices.ProtocolGateway.Mqtt.MqttAdapter.ShutdownOnError(IChannelHandlerContext context, String scope, Exception error) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Mqtt\MqttAdapter.cs:line 1010
   at Microsoft.Azure.Devices.ProtocolGateway.Mqtt.MqttAdapter.ExceptionCaught(IChannelHandlerContext context, Exception exception) in D:\src\azure-iot-protocol-gateway\src\ProtocolGateway.Core\Mqtt\MqttAdapter.cs:line 194
   at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeExceptionCaught(Exception cause)] , EventName : WarningInfo, Timestamp : 2018-08-03T10:00:51.6959329Z, ProcessId : 17892, ThreadId : 18112


Server cleanup did not complete in time.

What step am I missing?