-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Networking issue when using all libraries provided by ldd command #3
Comments
Possibly AWS Lambda image has changed but talking 6 months back, I was doing network calls used the carried over libcurl and didn't face any issues with DNS resolving. Is the issue reproducible on other DNS addresses? Can you supply a sample code please? |
This is the code from import Foundation
import Dispatch
let request = URLRequest(url: URL(string: "https://raw.githubusercontent.com/nikola-mladenovic/AwsSwiftSign/master/README.md")!)
let session = URLSession(configuration: .default)
let semaphore = DispatchSemaphore(value: 0)
session.dataTask(with: request, completionHandler: { data, response, error in
if let statusCode = (response as? HTTPURLResponse)?.statusCode {
print("status code: \(statusCode)")
}
if let error = error {
print("error code: \(error._code)")
print("error domain: \(error._domain)")
print("error desc: \(error.localizedDescription)")
}
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
semaphore.signal()
}).resume()
_ = semaphore.wait(timeout: DispatchTime.distantFuture) I tried to avoid AWS URLs for this example. Using To make this a bit easier to test, here're the two zip files, one with
Another useful information is that removing |
Thanks – will have a look |
Hi , I Have the same problem, did anyone find a solution ? |
You now also have to exclude |
When creating a Swift executable that is using networking, (e.g to communicate with other AWS components, or any other internet resource), the host name cannot be found.
After looking a bit deeper, it turns out the issue is with some of the libraries copied from Ubuntu container used to compile Swift executable (i.e
libcurl.so.4
and its dependents).After manually removing
libcurl.so.4
, the executable started using/usr/lib64/libcurl.so.4
provided by the AWS Lambda OS, the host names were successfully resolved.Hopefully this information will be useful for anyone trying to perform any network related actions inside Swift executables running on Lambda, and perhaps open a discussion whether copying all libraries provided by the
ldd
is sufficient / good enough.The text was updated successfully, but these errors were encountered: