Questions tagged [swift-nio]

Use the swift-nio tag for questions related to the Apple Swift NIO (non-blocking I/O) framework.

Swift NIO is a Swift framework released by Apple in March 2018. Think of it as a Netty port to the Swift programming language.

It can be used to write high performance protocol servers. For example HTTP endpoints, or any other kind of Internet protocol server, or client for that matter.

What Apple says:

SwiftNIO is a cross-platform asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.

It's like Netty, but written for Swift.

57 questions
2
votes
2 answers

Getting all values for [EventLoopFuture] before proceeding

I have an array of values I map to multiple promises that give me each a EventLoopFuture. So I end up with a method that has a variable-size [EventLoopFuture], and I need all the responses to succeed before I can continue. If one or more of them…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
1
vote
1 answer

EventLoopFuture causing `Invalid state: unable to write message`

I'm using grpc-swift and the ClientInterceptor to add an auth token to requests. I have implemented the delegate method for send as follows override func send(_ part: GRPCClientRequestPart, promise: EventLoopPromise<()>?, context:…
sbarow
  • 2,759
  • 1
  • 22
  • 37
1
vote
1 answer

Vapor (SwiftNIO) Interfacing with Async Methods

I am trying to use an async method from a 3rd party library to get a string result from a URL public static func fetch(url: URL, completion: @escaping (Result) -> Void) { inside a Vapor Swift request handler. func getHandler(_ req:…
Wendell
  • 474
  • 3
  • 12
1
vote
1 answer

Swift Vapor 4 upload , validate , resize an image file

I am trying to post a photo to the vapor 4 server. I am sending a Team name as a string and an image as data. struct SendTeam: Content { var name: String var img: Data } I want to upload the photo after validating its size to be not more…
mercury
  • 2,390
  • 3
  • 30
  • 39
1
vote
2 answers

Swift / SwiftNIO / Vapor: wait() or similar inside EventLoop & equivalent to JavaScript‘s Promise.all()

I‘m starting with Vapor 4 and got stuck at the very beginning of my journey. I know Promises in JavaScript and I think I have an understanding of Swift‘s Futures. I think my problem is the fact, that sadly most tutorials out there use wait() to keep…
Robert
  • 431
  • 7
  • 19
1
vote
1 answer

channelRead not being called in Swift-NIO Datagram's ChannelInboundHandler

I am trying to capture a UDP video stream within a (fresh) vapor application running in Xcode. The data is being streamed by ffmpeg and I can successfully view the stream on the target machine using VLC, which is also the one running the vapor…
Nick
  • 4,820
  • 18
  • 31
  • 47
1
vote
0 answers

Apple Secure Transport API is deprecated, what alternatives are there

Hi according to this the API is deprecated and considered legacy. It is not specific about when it will be removed. They recommend using Network, though it doesn't have a low-level API for alternative transports/physical layers. I plan on using it…
Climax
  • 663
  • 6
  • 17
1
vote
1 answer

Error when mapping an EventLoopFuture to an expected Type

I've tried mapping, flat mapping, creating an EventLoopFuture of Post, etc... I'm trying to return two db.queries that create separate arrays of content to be rendered on the req.view.render, which returns an EventLoopFuture. My error is:…
DIV
  • 223
  • 1
  • 2
  • 11
1
vote
1 answer

Using a Swift Timer in a MacOS command-line-tool / daemon which uses Swift-NIO for networking: RunLoop vs wait issue

I'm converting a Swift MacOS command-line tool/daemon to use Swift-NIO for networking. This is my first Swift-NIO project. The tool fires a timer every 0.1 second. Here's the line at the bottom of main.swift which fires up the daemon/runloop,…
Darrell Root
  • 724
  • 8
  • 19
1
vote
1 answer

iOS 13 Certificate Pinning with Weak Cipher stopped working But works fine in iOS 12

I am curious into the Passing Weak Cipher through NWProtocolTLS.Options(). Because its working fine in iOS 12 but on iOS 13 Apple they did some changes I guess so it is stopped taking it. One thing here is: How OpenSSL it takes weak…
1
vote
1 answer

How to write a file downloaded with SwiftNIO AsyncHTTPClient to the filesystem?

I would like to download a large file (hundreds of megabytes) with the AsyncHTTPClient library based on SwiftNIO. I would like this file to be streamed to the filesystem, while consuming as little RAM as possible (ideally it shouldn't keep the whole…
Max Desiatov
  • 5,087
  • 3
  • 48
  • 56
1
vote
1 answer

Rewriting looping blocking code to SwiftNIO style non-blocking code

I'm working on a driver that will read data from the network. It doesn't know how much is in a response, other than that when it tries to read and gets 0 bytes back, it is done. So my blocking Swift code looks naively like this: func…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
1
vote
0 answers

Swift Digest Authentication async-http-client

I am trying to create a digest authentication using swift on top of swiftNIO. At the end I get the following error: The operation couldn’t be completed. (NIO.NIOConnectionError error 1.) Here my way to do: // in the delegate I create my…
Arnold Schmid
  • 163
  • 12
1
vote
1 answer

Swift-NIO TCP Client auto reconnect

I write a TCP Client in Swift-NIO to connect Netty TCP Server. I want tcp client can auto reconnect when needed. import Foundation import NIO class MessageHandler: ChannelInboundHandler { let notificationMessage = NSNotification.Name(rawValue:…
mymbrooks
  • 43
  • 5
1
vote
1 answer

Apple SwiftNIO in CloudRun - is this possible?

I need to implement the following functionality. Client side: iOS (and Android) App calling a web service Server side: Web service on Goolge Cloud. The server side should have HTTP/2, TLS 1.3 IBM Kitura makes very easy to generate the client code…
thstart
  • 397
  • 3
  • 15