[Linux] Swift 5.1 URLSession unable to handle multiple concurrent connections

Hi guys,

sorry if this is a wrong place to bring this. I am using SwiftyRequest under official Linux docker image for Swift 5.1 and getting ton of timeouts (error 1001) when firing up multiple simultaneous POST requests at the same time. Everything working fine under Swift 5.0.

Logged as a bug [SR-11549] Siwft 5.1 URLSession on Linux fails to handle multiple concurrent requests · Issue #3287 · apple/swift-corelibs-foundation · GitHub and created a sample application to quickly reproduce (GitHub - mman/swifty-request-failer).

My limited lldb testing inside the swift 5.1 docker image points towards the timeout coming straight from the URLSession.

Please let me know if there is anything else I can do to help this get resolved,
Martin

I am really sorry to be so blunt but URLSession on Linux on Swift 5.1 is really broken and I would urge you to not use it at the moment. It seems to close essentially random unrelated file descriptors (SR-11557 which can lead to hangs (most likely), crashes, or worse...

3 Likes

What alternatives are there currently?

I'd recommend async-http-client. If there is something that's not currently supported that you need, please file an issue (same if docs are missing).

2 Likes

If I understand correctly from their github page, the latest release 3.0.0 on Sep 27 of SwiftyRequest is built upon the Swift-NIO based async-http-client so that might help with the suggestions below.

1 Like