profile
viewpoint
Artem Redkin artemredkin Apple London, UK

swift-server/async-http-client 396

HTTP client library built on SwiftNIO

artemredkin/async-http-client 0

HTTP client library built on SwiftNIO

artemredkin/sswg 0

Swift Server Working Group (SSWG)

artemredkin/swift-crypto 0

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.

artemredkin/swift-nio 0

Event-driven network application framework for high performance protocol servers & clients, non-blocking.

artemredkin/swift-nio-extras 0

Useful code around SwiftNIO.

artemredkin/swift-nio-http2 0

HTTP/2 support for SwiftNIO

artemredkin/swift-nio-ssh 0

SwiftNIO SSH is a programmatic implementation of SSH using SwiftNIO

artemredkin/swift-nio-ssl 0

TLS Support for SwiftNIO, based on BoringSSL.

startedkuglee/TermiWatch

started time in 13 hours

fork ktoso/alchemy

Elegant, batteries included web framework for Swift.

fork in 3 days

startedalchemy-swift/alchemy

started time in 3 days

created repositoryweissi/fake-package

created time in 3 days

issue closedswift-server/async-http-client

Sharing an HTTPClient in AWSLambda

Is there any recommendations regarding maintaining an AWSClient (from Soto) and an HTTPClient from AsyncHttpClient with a Lambda? I’m using a Singleton Application to store each. However I am continually getting:

0x55b0dc3c3c8d, Swift runtime failure: precondition failure at /src/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/HTTPClient.swift:0

Which I believe come from one of the preconditions here:

        case .delegate(on: let eventLoop):
            precondition(self.eventLoopGroup.makeIterator().contains { $0 === eventLoop }, "Provided EventLoop must be part of clients EventLoopGroup.")
            taskEL = eventLoop
        case .delegateAndChannel(on: let eventLoop):
            precondition(self.eventLoopGroup.makeIterator().contains { $0 === eventLoop }, "Provided EventLoop must be part of clients EventLoopGroup.")
            taskEL = eventLoop

I’m trying to replicate the suggested mechanism which Soto recommends for Vapor 4 in the Lambda so I have an Application class with these props:

  public lazy var eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: self.configuration.numberOfThreads)
  public lazy var httpClient: HTTPClient = {
    AsyncHTTPClient.HTTPClient(eventLoopGroupProvider: .shared(self.eventLoopGroup))
  }()
  public lazy var awsClient: AWSClient = {
    let credentialProvider: CredentialProviderFactory
    credentialProvider = self.configuration.aws.access.map(CredentialProviderFactory.static) ?? .default
    return AWSClient(credentialProvider: credentialProvider, httpClientProvider: .shared(self.httpClient))
  }()

then in main.swift:

Application.shared.run(ApplicationHandler())

closed time in 4 days

leogdion

issue commentswift-server/async-http-client

Sharing an HTTPClient in AWSLambda

Hey @Lukasa this can be closed. Once I realized there was an instance of Lambda.run which takes a factory with the InitializationContext (containing the EventLoop) I was good. Thank you

leogdion

comment created time in 4 days

pull request commentswift-server/async-http-client

Add NIOTransportServices TLS Configuration options

Hmm, ok. Let's get going with everything but the identity stuff, and we can schedule the PKCS#12 work for SwiftNIO SSL.

adam-fowler

comment created time in 4 days

fork glbrntt/swift-source-compat-suite

The infrastructure and project index comprising the Swift source compatibility suite.

fork in 4 days

pull request commentswift-server/async-http-client

Add NIOTransportServices TLS Configuration options

@adam-fowler What's your opinion on having AHC define its own TLS configuration structure that abstracts over this mess?

I think that is something we could aspire to. But that'd be a breaking change and would have to wait for v2.0. I'm not sure what is the full list of parameters from TLSConfiguration that apply to AHC. Also how do we support features not available in NIOTS but available in NIOSSL?

In the immediate future we can provide additional support for trust root certificates, application protocols via the TLSConfiguration we already have and if you supply the pkcs#12 generation we can get SecIdentity equivalent of a certificate chain and private key working.

adam-fowler

comment created time in 5 days

pull request commentswift-server/async-http-client

Add NIOTransportServices TLS Configuration options

@adam-fowler What's your opinion on having AHC define its own TLS configuration structure that abstracts over this mess?

adam-fowler

comment created time in 5 days

pull request commentswift-server/async-http-client

Add NIOTransportServices TLS Configuration options

Anymore thoughts on this? I can implement the non SecIdentity code for TLSConfiguration already. If the desire is to use TLSConfiguration for NIOTS as well.

adam-fowler

comment created time in 6 days

fork ktoso/swift-source-compat-suite

The infrastructure and project index comprising the Swift source compatibility suite.

fork in 7 days

startedapple/swift-source-compat-suite

started time in 7 days

issue commentswift-server/async-http-client

Access to ConnectionPool.count should be thread safe

@weissi has a good reference for a TSAN issue in 5.3 that manifests this way.

ya-pulser

comment created time in 7 days

issue commentswift-server/async-http-client

Access to ConnectionPool.count should be thread safe

I believe we’re done here: see https://github.com/swift-server/async-http-client/pull/319#discussion_r530515030 for more reasoning.

ya-pulser

comment created time in 7 days

issue closedswift-server/async-http-client

Thread Sanitizer issues with release version of code

I was using AsyncHTTPClient to test another system and wanted to use the thread sanitizer but AHC keeps throwing up an issue when IdlePoolConnectionHandler.channelInactive is calling HTTP1ConnectionProvider.remoteClosed.

To verify the issue wasn't related to my work I ran the following in the async-http-client repository

swift test -c release --sanitize=thread -Xswiftc -enable-testing

There appear to be quite a number of issues, but this one is the most frequent. Interestingly there doesn't appear to be any issues when compiling debug

Here is the output

WARNING: ThreadSanitizer: data race (pid=25186)
  Write of size 8 at 0x7b3000001900 by thread T12 (mutexes: write M2004):
    #0 specialized _NativeDictionary._delete(at:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x176f4)
    #1 specialized Dictionary._Variant.removeValue(forKey:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x166d3)
    #2 HTTP1ConnectionProvider.closeAndDelete() ConnectionPool.swift:389 (async-http-clientPackageTests:x86_64+0x11e77)
    #3 HTTP1ConnectionProvider.execute(_:logger:) ConnectionPool.swift:268 (async-http-clientPackageTests:x86_64+0xbc12)
    #4 HTTP1ConnectionProvider.remoteClosed(connection:logger:) ConnectionPool.swift:377 (async-http-clientPackageTests:x86_64+0x1198b)
    #5 IdlePoolConnectionHandler.channelInactive(context:) Connection.swift:134 (async-http-clientPackageTests:x86_64+0x2e57)
    #6 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance IdlePoolConnectionHandler <compiler-generated> (async-http-clientPackageTests:x86_64+0x32a3)
    #7 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #8 ByteToMessageHandler.channelInactive(context:) Codec.swift:669 (async-http-clientPackageTests:x86_64+0x3c0e2b)
    #9 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance ByteToMessageHandler<A> <compiler-generated> (async-http-clientPackageTests:x86_64+0x3c0f59)
    #10 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #11 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1362 (async-http-clientPackageTests:x86_64+0x3a6827)
    #12 _ChannelInboundHandler.channelInactive(context:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393231)
    #13 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance HTTPClient.NWErrorHandler <compiler-generated> (async-http-clientPackageTests:x86_64+0x77ab9)
    #14 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #15 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance ServerBootstrap.AcceptHandler <compiler-generated>:287 (async-http-clientPackageTests:x86_64+0x3931d1)
    #16 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance BackPressureHandler <null>:2 (async-http-clientPackageTests:x86_64+0x394e69)
    #17 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #18 ChannelPipeline.fireChannelInactive() ChannelPipeline.swift:572 (async-http-clientPackageTests:x86_64+0x3a4700)
    #19 specialized StateManagedChannel.close0(error:mode:promise:) StateManagedChannel.swift:210 (async-http-clientPackageTests:x86_64+0x555a98)
    #20 protocol witness for ChannelCore.close0(error:mode:promise:) in conformance NIOTSConnectionChannel <compiler-generated> (async-http-clientPackageTests:x86_64+0x57c0f9)
    #21 specialized HeadChannelHandler.close(context:mode:promise:) ChannelPipeline.swift:1001 (async-http-clientPackageTests:x86_64+0x3ae222)
    #22 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance HeadChannelHandler <compiler-generated>:1000 (async-http-clientPackageTests:x86_64+0x3a8c79)
    #23 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #24 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #25 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance AcceptBackoffHandler <null>:2 (async-http-clientPackageTests:x86_64+0x393f29)
    #26 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #27 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1493 (async-http-clientPackageTests:x86_64+0x3a6052)
    #28 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #29 _ChannelOutboundHandler.close(context:mode:promise:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393739)
    #30 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance HTTPRequestEncoder <compiler-generated> (async-http-clientPackageTests:x86_64+0x4b670c)
    #31 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #32 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #33 _ChannelOutboundHandler.close(context:mode:promise:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393739)
    #34 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance <> ByteToMessageHandler<A> <null>:2 (async-http-clientPackageTests:x86_64+0x3943c9)
    #35 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #36 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1493 (async-http-clientPackageTests:x86_64+0x3a6052)
    #37 ChannelPipeline.close(mode:promise:) ChannelPipeline.swift:642 (async-http-clientPackageTests:x86_64+0x3a0227)
    #38 Channel.close(mode:promise:) Channel.swift:209 (async-http-clientPackageTests:x86_64+0x390b03)
    #39 protocol witness for ChannelOutboundInvoker.close(mode:promise:) in conformance NIOTSConnectionChannel <compiler-generated> (async-http-clientPackageTests:x86_64+0x55705b)
    #40 specialized ChannelOutboundInvoker.close(mode:file:line:) ChannelInvoker.swift:154 (async-http-clientPackageTests:x86_64+0x39a223)
    #41 ChannelOutboundInvoker.close(mode:file:line:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x399c28)
    #42 closure #5 in HTTP1ConnectionProvider.close() ConnectionPool.swift:405 (async-http-clientPackageTests:x86_64+0x1356c)
    #43 partial apply for closure #5 in HTTP1ConnectionProvider.close() <compiler-generated> (async-http-clientPackageTests:x86_64+0x1f663)
    #44 thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>) <compiler-generated> (async-http-clientPackageTests:x86_64+0x2747)
    #45 partial apply for thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>) <compiler-generated> (async-http-clientPackageTests:x86_64+0x6ac1)
    #46 specialized closure #1 in EventLoopFuture.flatMap<A>(file:line:_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x62181)
    #47 partial apply for specialized closure #1 in EventLoopFuture.flatMap<A>(file:line:_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x6b17)
    #48 specialized closure #1 in EventLoopFuture._whenComplete(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x15332)
    #49 specialized closure #1 in EventLoopFuture._whenComplete(_:) <null>:2 (async-http-clientPackageTests:x86_64+0x22029)
    #50 specialized closure #1 in EventLoopFuture._whenComplete(_:) <null>:2 (async-http-clientPackageTests:x86_64+0x21f39)
    #51 partial apply for specialized closure #1 in EventLoopFuture._whenComplete(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x67df)
    #52 closure #1 in EventLoopFuture._whenComplete(_:)specialized partial apply <null>:2 (async-http-clientPackageTests:x86_64+0x6e83)
    #53 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (async-http-clientPackageTests:x86_64+0x311e2)
    #54 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x37c6)
    #55 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x37c6)

  Previous read of size 8 at 0x7b3000001900 by main thread:
    #0 specialized Collection.map<A>(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x7e76)
    #1 specialized HTTPClient.shutdown(requiresCleanClose:queue:_:) HTTPClient.swift:202 (async-http-clientPackageTests:x86_64+0x3e973)
    #2 HTTPClient.syncShutdown(requiresCleanClose:) HTTPClient.swift:147 (async-http-clientPackageTests:x86_64+0x310b3)
    #3 implicit closure #1 in $defer #1 () in HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xc1f9e)
    #4 partial apply for implicit closure #1 in $defer #1 () in HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xc6a9c)
    #5 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (async-http-clientPackageTests:x86_64+0x961b0)
    #6 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (async-http-clientPackageTests:x86_64+0xc23b8)
    #7 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <null>:2 (async-http-clientPackageTests:x86_64+0xd9b20)
    #8 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <null>:2 (async-http-clientPackageTests:x86_64+0xd8b98)
    #9 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #10 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Location is heap block of size 184 at 0x7b30000018c0 allocated by main thread:
    #0 __sanitizer_mz_malloc <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x5277a)
    #1 _malloc_zone_malloc <null>:2 (libsystem_malloc.dylib:x86_64+0x1bdfd)
    #2 specialized _NativeDictionary.mutatingFind(_:isUnique:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x16833)
    #3 specialized Dictionary._Variant.setValue(_:forKey:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x1648c)
    #4 closure #1 in ConnectionPool.getConnection(_:preference:taskEventLoop:deadline:setupComplete:logger:) ConnectionPool.swift:90 (async-http-clientPackageTests:x86_64+0x779f)
    #5 HTTPClient.execute<A>(request:delegate:eventLoop:deadline:logger:) HTTPClient.swift:542 (async-http-clientPackageTests:x86_64+0x34ce9)
    #6 HTTPClient.execute<A>(request:delegate:deadline:logger:) HTTPClient.swift:455 (async-http-clientPackageTests:x86_64+0x339d4)
    #7 HTTPClient.execute(request:deadline:logger:) HTTPClient.swift:401 (async-http-clientPackageTests:x86_64+0x3348d)
    #8 HTTPClient.execute(_:url:body:deadline:logger:) HTTPClient.swift:336 (async-http-clientPackageTests:x86_64+0x32897)
    #9 HTTPClient.post(url:body:deadline:logger:) HTTPClient.swift:261 (async-http-clientPackageTests:x86_64+0x320c4)
    #10 HTTPClient.post(url:body:deadline:) HTTPClient.swift:250 (async-http-clientPackageTests:x86_64+0x31fce)
    #11 HTTPClientInternalTests.testProxyStreaming() HTTPClientInternalTests.swift:186 (async-http-clientPackageTests:x86_64+0xb34be)
    #12 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #13 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Mutex M2004 (0x7b1000011740) created at:
    #0 pthread_mutex_init <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2e913)
    #1 Lock.init() lock.swift:48 (async-http-clientPackageTests:x86_64+0x4a4ba4)
    #2 specialized HTTPClient.init(eventLoopGroupProvider:configuration:backgroundActivityLogger:) HTTPClient.swift:111 (async-http-clientPackageTests:x86_64+0x3de50)
    #3 HTTPClient.__allocating_init(eventLoopGroupProvider:configuration:backgroundActivityLogger:) HTTPClient.swift:92 (async-http-clientPackageTests:x86_64+0x30918)
    #4 HTTPClient.__allocating_init(eventLoopGroupProvider:configuration:) HTTPClient.swift:82 (async-http-clientPackageTests:x86_64+0x30856)
    #5 HTTPClientInternalTests.testProxyStreaming() HTTPClientInternalTests.swift:166 (async-http-clientPackageTests:x86_64+0xb3215)
    #6 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #7 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Thread T12 (tid=30683246, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race <compiler-generated> in specialized _NativeDictionary._delete(at:)

closed time in 7 days

adam-fowler

issue commentswift-server/async-http-client

Thread Sanitizer issues with release version of code

I believe this is a dupe of #318

adam-fowler

comment created time in 7 days

issue openedswift-server/async-http-client

Thread Sanitizer issues with release version of code

I was using AsyncHTTPClient to test another system and wanted to use the thread sanitizer but AHC keeps throwing up an issue when IdlePoolConnectionHandler.channelInactive is calling HTTP1ConnectionProvider.remoteClosed.

To verify the issue wasn't related to my work I ran the following in the async-http-client repository

swift test -c release --sanitize=thread -Xswiftc -enable-testing

There appear to be quite a number of issues, but this one is the most frequent. Interestingly there doesn't appear to be any issues when compiling debug

Here is the output

WARNING: ThreadSanitizer: data race (pid=25186)
  Write of size 8 at 0x7b3000001900 by thread T12 (mutexes: write M2004):
    #0 specialized _NativeDictionary._delete(at:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x176f4)
    #1 specialized Dictionary._Variant.removeValue(forKey:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x166d3)
    #2 HTTP1ConnectionProvider.closeAndDelete() ConnectionPool.swift:389 (async-http-clientPackageTests:x86_64+0x11e77)
    #3 HTTP1ConnectionProvider.execute(_:logger:) ConnectionPool.swift:268 (async-http-clientPackageTests:x86_64+0xbc12)
    #4 HTTP1ConnectionProvider.remoteClosed(connection:logger:) ConnectionPool.swift:377 (async-http-clientPackageTests:x86_64+0x1198b)
    #5 IdlePoolConnectionHandler.channelInactive(context:) Connection.swift:134 (async-http-clientPackageTests:x86_64+0x2e57)
    #6 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance IdlePoolConnectionHandler <compiler-generated> (async-http-clientPackageTests:x86_64+0x32a3)
    #7 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #8 ByteToMessageHandler.channelInactive(context:) Codec.swift:669 (async-http-clientPackageTests:x86_64+0x3c0e2b)
    #9 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance ByteToMessageHandler<A> <compiler-generated> (async-http-clientPackageTests:x86_64+0x3c0f59)
    #10 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #11 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1362 (async-http-clientPackageTests:x86_64+0x3a6827)
    #12 _ChannelInboundHandler.channelInactive(context:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393231)
    #13 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance HTTPClient.NWErrorHandler <compiler-generated> (async-http-clientPackageTests:x86_64+0x77ab9)
    #14 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #15 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance ServerBootstrap.AcceptHandler <compiler-generated>:287 (async-http-clientPackageTests:x86_64+0x3931d1)
    #16 protocol witness for _ChannelInboundHandler.channelInactive(context:) in conformance BackPressureHandler <null>:2 (async-http-clientPackageTests:x86_64+0x394e69)
    #17 ChannelHandlerContext.invokeChannelInactive() ChannelPipeline.swift:1360 (async-http-clientPackageTests:x86_64+0x3a6806)
    #18 ChannelPipeline.fireChannelInactive() ChannelPipeline.swift:572 (async-http-clientPackageTests:x86_64+0x3a4700)
    #19 specialized StateManagedChannel.close0(error:mode:promise:) StateManagedChannel.swift:210 (async-http-clientPackageTests:x86_64+0x555a98)
    #20 protocol witness for ChannelCore.close0(error:mode:promise:) in conformance NIOTSConnectionChannel <compiler-generated> (async-http-clientPackageTests:x86_64+0x57c0f9)
    #21 specialized HeadChannelHandler.close(context:mode:promise:) ChannelPipeline.swift:1001 (async-http-clientPackageTests:x86_64+0x3ae222)
    #22 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance HeadChannelHandler <compiler-generated>:1000 (async-http-clientPackageTests:x86_64+0x3a8c79)
    #23 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #24 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #25 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance AcceptBackoffHandler <null>:2 (async-http-clientPackageTests:x86_64+0x393f29)
    #26 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #27 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1493 (async-http-clientPackageTests:x86_64+0x3a6052)
    #28 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #29 _ChannelOutboundHandler.close(context:mode:promise:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393739)
    #30 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance HTTPRequestEncoder <compiler-generated> (async-http-clientPackageTests:x86_64+0x4b670c)
    #31 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #32 specialized _ChannelOutboundHandler.close(context:mode:promise:) ChannelHandler.swift:261 (async-http-clientPackageTests:x86_64+0x3944b2)
    #33 _ChannelOutboundHandler.close(context:mode:promise:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x393739)
    #34 protocol witness for _ChannelOutboundHandler.close(context:mode:promise:) in conformance <> ByteToMessageHandler<A> <null>:2 (async-http-clientPackageTests:x86_64+0x3943c9)
    #35 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1491 (async-http-clientPackageTests:x86_64+0x3a602a)
    #36 ChannelHandlerContext.invokeClose(mode:promise:) ChannelPipeline.swift:1493 (async-http-clientPackageTests:x86_64+0x3a6052)
    #37 ChannelPipeline.close(mode:promise:) ChannelPipeline.swift:642 (async-http-clientPackageTests:x86_64+0x3a0227)
    #38 Channel.close(mode:promise:) Channel.swift:209 (async-http-clientPackageTests:x86_64+0x390b03)
    #39 protocol witness for ChannelOutboundInvoker.close(mode:promise:) in conformance NIOTSConnectionChannel <compiler-generated> (async-http-clientPackageTests:x86_64+0x55705b)
    #40 specialized ChannelOutboundInvoker.close(mode:file:line:) ChannelInvoker.swift:154 (async-http-clientPackageTests:x86_64+0x39a223)
    #41 ChannelOutboundInvoker.close(mode:file:line:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x399c28)
    #42 closure #5 in HTTP1ConnectionProvider.close() ConnectionPool.swift:405 (async-http-clientPackageTests:x86_64+0x1356c)
    #43 partial apply for closure #5 in HTTP1ConnectionProvider.close() <compiler-generated> (async-http-clientPackageTests:x86_64+0x1f663)
    #44 thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>) <compiler-generated> (async-http-clientPackageTests:x86_64+0x2747)
    #45 partial apply for thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>) <compiler-generated> (async-http-clientPackageTests:x86_64+0x6ac1)
    #46 specialized closure #1 in EventLoopFuture.flatMap<A>(file:line:_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x62181)
    #47 partial apply for specialized closure #1 in EventLoopFuture.flatMap<A>(file:line:_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x6b17)
    #48 specialized closure #1 in EventLoopFuture._whenComplete(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x15332)
    #49 specialized closure #1 in EventLoopFuture._whenComplete(_:) <null>:2 (async-http-clientPackageTests:x86_64+0x22029)
    #50 specialized closure #1 in EventLoopFuture._whenComplete(_:) <null>:2 (async-http-clientPackageTests:x86_64+0x21f39)
    #51 partial apply for specialized closure #1 in EventLoopFuture._whenComplete(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x67df)
    #52 closure #1 in EventLoopFuture._whenComplete(_:)specialized partial apply <null>:2 (async-http-clientPackageTests:x86_64+0x6e83)
    #53 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (async-http-clientPackageTests:x86_64+0x311e2)
    #54 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x37c6)
    #55 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x37c6)

  Previous read of size 8 at 0x7b3000001900 by main thread:
    #0 specialized Collection.map<A>(_:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x7e76)
    #1 specialized HTTPClient.shutdown(requiresCleanClose:queue:_:) HTTPClient.swift:202 (async-http-clientPackageTests:x86_64+0x3e973)
    #2 HTTPClient.syncShutdown(requiresCleanClose:) HTTPClient.swift:147 (async-http-clientPackageTests:x86_64+0x310b3)
    #3 implicit closure #1 in $defer #1 () in HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xc1f9e)
    #4 partial apply for implicit closure #1 in $defer #1 () in HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xc6a9c)
    #5 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (async-http-clientPackageTests:x86_64+0x961b0)
    #6 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (async-http-clientPackageTests:x86_64+0xc23b8)
    #7 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <null>:2 (async-http-clientPackageTests:x86_64+0xd9b20)
    #8 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <null>:2 (async-http-clientPackageTests:x86_64+0xd8b98)
    #9 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #10 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Location is heap block of size 184 at 0x7b30000018c0 allocated by main thread:
    #0 __sanitizer_mz_malloc <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x5277a)
    #1 _malloc_zone_malloc <null>:2 (libsystem_malloc.dylib:x86_64+0x1bdfd)
    #2 specialized _NativeDictionary.mutatingFind(_:isUnique:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x16833)
    #3 specialized Dictionary._Variant.setValue(_:forKey:) <compiler-generated> (async-http-clientPackageTests:x86_64+0x1648c)
    #4 closure #1 in ConnectionPool.getConnection(_:preference:taskEventLoop:deadline:setupComplete:logger:) ConnectionPool.swift:90 (async-http-clientPackageTests:x86_64+0x779f)
    #5 HTTPClient.execute<A>(request:delegate:eventLoop:deadline:logger:) HTTPClient.swift:542 (async-http-clientPackageTests:x86_64+0x34ce9)
    #6 HTTPClient.execute<A>(request:delegate:deadline:logger:) HTTPClient.swift:455 (async-http-clientPackageTests:x86_64+0x339d4)
    #7 HTTPClient.execute(request:deadline:logger:) HTTPClient.swift:401 (async-http-clientPackageTests:x86_64+0x3348d)
    #8 HTTPClient.execute(_:url:body:deadline:logger:) HTTPClient.swift:336 (async-http-clientPackageTests:x86_64+0x32897)
    #9 HTTPClient.post(url:body:deadline:logger:) HTTPClient.swift:261 (async-http-clientPackageTests:x86_64+0x320c4)
    #10 HTTPClient.post(url:body:deadline:) HTTPClient.swift:250 (async-http-clientPackageTests:x86_64+0x31fce)
    #11 HTTPClientInternalTests.testProxyStreaming() HTTPClientInternalTests.swift:186 (async-http-clientPackageTests:x86_64+0xb34be)
    #12 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #13 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Mutex M2004 (0x7b1000011740) created at:
    #0 pthread_mutex_init <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2e913)
    #1 Lock.init() lock.swift:48 (async-http-clientPackageTests:x86_64+0x4a4ba4)
    #2 specialized HTTPClient.init(eventLoopGroupProvider:configuration:backgroundActivityLogger:) HTTPClient.swift:111 (async-http-clientPackageTests:x86_64+0x3de50)
    #3 HTTPClient.__allocating_init(eventLoopGroupProvider:configuration:backgroundActivityLogger:) HTTPClient.swift:92 (async-http-clientPackageTests:x86_64+0x30918)
    #4 HTTPClient.__allocating_init(eventLoopGroupProvider:configuration:) HTTPClient.swift:82 (async-http-clientPackageTests:x86_64+0x30856)
    #5 HTTPClientInternalTests.testProxyStreaming() HTTPClientInternalTests.swift:166 (async-http-clientPackageTests:x86_64+0xb3215)
    #6 @objc HTTPClientInternalTests.testProxyStreaming() <compiler-generated> (async-http-clientPackageTests:x86_64+0xb3ff0)
    #7 __invoking___ <null>:3 (CoreFoundation:x86_64h+0x6455b)

  Thread T12 (tid=30683246, running) is a GCD worker thread

SUMMARY: ThreadSanitizer: data race <compiler-generated> in specialized _NativeDictionary._delete(at:)

created time in 7 days

issue commentswift-server/async-http-client

Sharing an HTTPClient in AWSLambda

If one of those preconditions are firing, it suggests that the call site is requesting a specific event loop for use with the request, and that event loop isn’t in the ELG you configured the HTTP client with. Do you have a full traceback?

leogdion

comment created time in 9 days

issue openedswift-server/async-http-client

Sharing an HTTPClient in AWSLambda

Is there any recommendations regarding maintaining an AWSClient (from Soto) and an HTTPClient from AsyncHttpClient with a Lambda? I’m using a Singleton Application to store each. However I am continually getting:

0x55b0dc3c3c8d, Swift runtime failure: precondition failure at /src/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/HTTPClient.swift:0

Which I believe come from one of the preconditions here:

        case .delegate(on: let eventLoop):
            precondition(self.eventLoopGroup.makeIterator().contains { $0 === eventLoop }, "Provided EventLoop must be part of clients EventLoopGroup.")
            taskEL = eventLoop
        case .delegateAndChannel(on: let eventLoop):
            precondition(self.eventLoopGroup.makeIterator().contains { $0 === eventLoop }, "Provided EventLoop must be part of clients EventLoopGroup.")
            taskEL = eventLoop

I’m trying to replicate the suggested mechanism which Soto recommends for Vapor 4 in the Lambda so I have an Application class with these props:

  public lazy var eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: self.configuration.numberOfThreads)
  public lazy var httpClient: HTTPClient = {
    AsyncHTTPClient.HTTPClient(eventLoopGroupProvider: .shared(self.eventLoopGroup))
  }()
  public lazy var awsClient: AWSClient = {
    let credentialProvider: CredentialProviderFactory
    credentialProvider = self.configuration.aws.access.map(CredentialProviderFactory.static) ?? .default
    return AWSClient(credentialProvider: credentialProvider, httpClientProvider: .shared(self.httpClient))
  }()

then in main.swift:

Application.shared.run(ApplicationHandler())

created time in 9 days

created repositorytomerd/tomerd.github.io

created time in 10 days

fork fabianfett/swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence

swift.org

fork in 10 days

issue commentswift-server/async-http-client

ResponseDelegate can invoke `didReceiveBodyPart` before the previous run's future returned

The test in #273 also shows that the HTTPClient finishes before all the ResponseDelegate tasks are finished. Would this be considered a different bug?

This would be fixed by fixing the above bug, but this could possibly be resolved without fixing the above. I believe it is a more serious issue than the original bug filed. Should this get its own issue? It has been sitting around for 6 months now.

adam-fowler

comment created time in 12 days

Pull request review commentswift-server/async-http-client

Add NIOTransportServices TLS Configuration options

 public class HTTPClient {     public struct Configuration {         /// TLS configuration, defaults to `TLSConfiguration.forClient()`.         public var tlsConfiguration: Optional<TLSConfiguration>+        #if canImport(Network)+            /// TLS configuration, defaults to `TLSConfiguration.forClient()`.

I wonder, can that structure live in NIOTS?

I don't really want it to at this early stage.

adam-fowler

comment created time in 13 days

issue commentswift-server/async-http-client

Connections not being closed, even when server sets the "Connection: close" header

Given that these are plaintext, can we get a packet capture of what HTTPClient is sending and receiving? HTTPClient sends different headers than curl, and so this may well be triggering different behaviour.

0xpablo

comment created time in 13 days

issue commentswift-server/async-http-client

Connections not being closed, even when server sets the "Connection: close" header

Sure! This is the output of my curl:

curl -v  -X "POST" "http://192.168.1.116:3000/api/v1/hvac"  -d $'{
  "systemid": 1,
  "zoneid": 0
}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.1.116...
* TCP_NODELAY set
* Connected to 192.168.1.116 (192.168.1.116) port 3000 (#0)
> POST /api/v1/hvac HTTP/1.1
> Host: 192.168.1.116:3000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 34
> 
* upload completely sent off: 34 out of 34 bytes
< HTTP/1.1 200 OK
< Server: Airzone-Athome gateway
< Connection: close
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: PUT,POST,DELETE,PATCH
< Content-Type: text/html
< Content-Length: 1505
< 
0xpablo

comment created time in 13 days

push eventswift-server/async-http-client

0xpablo

commit sha a72c5adce3986ff6b5092ae0464a8f2675087860

Fix Timeout snippet in README.md (#323)

view details

push time in 13 days

PR merged swift-server/async-http-client

Fix Timeout snippet in README.md patch-version-bump-only
+1 -1

6 comments

1 changed file

0xpablo

pr closed time in 13 days

pull request commentswift-server/async-http-client

Fix Timeout snippet in README.md

@swift-server-bot test this please

0xpablo

comment created time in 13 days

issue commentswift-server/async-http-client

Connections not being closed, even when server sets the "Connection: close" header

Do you have the full set of headers sent by the remote server? We do have code that should tear these down if Connection: close genuinely is being sent.

0xpablo

comment created time in 13 days

more