Azure / DotNetty

DotNetty project – a port of netty, event-driven asynchronous network application framework
Other
4.09k stars 977 forks source link

Client hangs when trying to write to secure channel #182

Closed Horusiath closed 7 years ago

Horusiath commented 7 years ago

I've already posted that on a gitter channel, but since it hasn't been responded for the last few days, I'm putting it here.

I'm trying to make a secure connection using TlsHandler, however when trying to push any data through the client it hangs and message is never received on the other side. I've managed to extract the issue into reproducible scenario: both client and server implementation can be seen here.

Cert has been generated by makecert for testing purposes.

The results of LoggingHandler logs are:

Server

warn: DotNetty.Transport.Channels.DefaultChannelId[0]
      -Dio.netty.processId: {0} (malformed)
dbug: DotNetty.Transport.Channels.DefaultChannelId[0]
      -Dio.netty.machineId: X2:X2:X2:X2:X2:X2:X2:X2 (auto-detected)
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.numHeapArenas: 8
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.pageSize: 8192
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.maxOrder: 11
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.chunkSize: 16777216
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.tinyCacheSize: 512
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.smallCacheSize: 256
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.normalCacheSize: 64
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.maxCachedBufferCapacity: 32768
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.cacheTrimInterval: 8192
dbug: DotNetty.Buffers.ByteBufferUtil[0]
      -Dio.netty.allocator.type: pooled
dbug: DotNetty.Common.ResourceLeakDetector[0]
      io.netty.leakDetection.level: simple
dbug: DotNetty.Common.ResourceLeakDetector[0]
      io.netty.leakDetection.maxRecords: 4
warn: DotNetty.Transport.Bootstrapping.ServerBootstrap[0]
      Unknown channel option: True
warn: DotNetty.Transport.Bootstrapping.ServerBootstrap[0]
      Unknown channel option: True
dbug: DotNetty.Handlers.Logging.LoggingHandler[0]
      [id: 0x059c610e, [::ffff:127.0.0.1]:2369 => [::ffff:127.0.0.1]:1337] REGISTERED
dbug: DotNetty.Handlers.Logging.LoggingHandler[0]
      [id: 0x059c610e, [::ffff:127.0.0.1]:2369 => [::ffff:127.0.0.1]:1337] ACTIVE

Client

warn: DotNetty.Transport.Channels.DefaultChannelId[0]
      -Dio.netty.processId: {0} (malformed)
dbug: DotNetty.Transport.Channels.DefaultChannelId[0]
      -Dio.netty.machineId: X2:X2:X2:X2:X2:X2:X2:X2 (auto-detected)
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.numHeapArenas: 8
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.pageSize: 8192
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.maxOrder: 11
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.chunkSize: 16777216
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.tinyCacheSize: 512
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.smallCacheSize: 256
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.normalCacheSize: 64
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.maxCachedBufferCapacity: 32768
dbug: DotNetty.Buffers.PooledByteBufferAllocator[0]
      -Dio.netty.allocator.cacheTrimInterval: 8192
dbug: DotNetty.Buffers.ByteBufferUtil[0]
      -Dio.netty.allocator.type: pooled
dbug: DotNetty.Common.ResourceLeakDetector[0]
      io.netty.leakDetection.level: simple
dbug: DotNetty.Common.ResourceLeakDetector[0]
      io.netty.leakDetection.maxRecords: 4

Client just hangs on WriteAndFlushAsync call, and from what you can see, server notified ACTIVE channel, however no RECEIVE event happened (no data has been received on the server side).

This issue occurs only when I'm trying to send data through pipeline with TlsHandler attached. When I remove it, everything works smooth. X509Certificate2 is loaded correctly.

Horusiath commented 7 years ago

It turned out, that the certificate I've used, was invalid (not self-signed or not inserted into cert store). However this issue (hanging on WriteAndFlushAsync) shouldn't happen anyway.

nayato commented 7 years ago

should be fine now, pls reopen if that's not the case.