soto-project / soto

Swift SDK for AWS that works on Linux, macOS and iOS
https://soto.codes
Apache License 2.0
868 stars 81 forks source link

try to use SES in Soto SDK with Vapor 4 but I have some error #708

Closed NerisD closed 5 months ago

NerisD commented 5 months ago

Describe the bug I want to use SES Services with Vapor 4 to send an Email with my own route.

I follow step by step the recommendation in Soto Doc to use Vapor 4.

But I got this error : AsyncHTTPClient/HTTPClient.swift:591: Precondition failed: Provided EventLoop must be part of clients EventLoopGroup.

Some one can give me some explanations or explain how can I implement Soto SES with Vapor.

Thanks :)

adam-fowler commented 5 months ago

Are you creating your AWSClient with httpClientProvider set to .createNew and when calling SES methods setting eventLoop to req.eventLoop? If so you are asking the HTTP client to run on an EventLoop from a different EventLoopGroup.

If you want to use the request event loop you need to use an HTTP client that uses the same EventLoopGroup. Luckily Vapor provides one. I believe you can get it via app.client.shared. You should then create your AWSClient as follows

let awsClient = AWSClient(httpClientProvider: .shared(app.client.shared))
adam-fowler commented 5 months ago

Converting this to a discussion, as it is not an issue