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
8
votes
1 answer

How to use EventLoopFuture in Swift properly?

I'm new to EventLoop futures and promises. My software stack: Backend in Go + gRPC iOS client in Swift + SwiftUI + GRPC + NIO I've got something to work and looking for suggestions on how to improve it since I'm a little lost in docs around .map,…
Maklaus
  • 538
  • 2
  • 16
  • 37
6
votes
2 answers

Running actions after file stream in Vapor 4

I run a website that handles large files (uploads and downloads). Currently I am transitioning the site from Perfect to Vapor. In Perfect, it is relatively simple to stream a file to users, and then perform some actions AFTER the file is done. I am…
MAH
  • 841
  • 6
  • 16
5
votes
1 answer

How do I make the app allow incoming network connections with SwiftNIO?

I am using MicroExpress to create a web server in a SwiftUI app. I can connect to the server when I am running the app in Simulator, but I cannot make it work on my real device. MicroExpress (based on SwiftNIO) creates a Webserver on the iPhone and…
user10471707
5
votes
2 answers

Creating and consuming a cursor with Vapor 3

This might be a can of worms, I'll do my best to describe the issue. We have a long running data processing job. Our database of actions is added to nightly and the outstanding actions are processed. It takes about 15 minutes to process nightly…
David Monagle
  • 1,701
  • 16
  • 19
4
votes
1 answer

Vapor Swift How to Configure Client Connection Timeout

I am using Vapor Swift to send GET / POST requests from the server-side using the below methods: req.application.client.get(<#T##url: URI##URI#>, headers: <#T##HTTPHeaders#>, beforeSend: <#T##(inout ClientRequest) throws ->…
Wendell
  • 474
  • 3
  • 12
4
votes
1 answer

Which event loop should I use in Swift NIO?

The example in the docs shows an existing reference to the EventLoop for use with creating a future. func getNetworkData(args) -> EventLoopFuture { let promise = eventLoop.makePromise(of: NetworkResponse.self) queue.async { …
joels
  • 7,249
  • 11
  • 53
  • 94
4
votes
1 answer

SwiftNIO: Send and receive UDP broadcast

I'm trying to build a TCP server with SwiftNIO. The server starts in the net, but the clients don't know the ip address. Therefore I want to start an UDP server as well and if the clients comes up, he sends a broadcast message to the net. The server…
Lupurus
  • 3,618
  • 2
  • 29
  • 59
4
votes
2 answers

Swift-NIO secured websocket server

I am trying to create websocket server and client in my iOS app, which i successfully managed to do with the help of sample implementation here. (https://github.com/apple/swift-nio/tree/master/Sources/NIOWebSocketServer) - so current working…
Appu Newbie
  • 123
  • 9
4
votes
1 answer

Using SwiftNIO and SwiftNIOHTTP2 as an HTTP2 client

I'm currently working on a simple HTTP2 client in Swift using SwiftNIO and the SwiftNIOHTTP2 beta. My implementation looks like this: let group = MultiThreadedEventLoopGroup(numberOfThreads: 1) let bootstrap = ClientBootstrap(group: group) …
strnmn
  • 555
  • 1
  • 6
  • 30
4
votes
2 answers

writeDataUnsupported in ChannelInboundHandler (Swift-NIO)

I am trying to make a simple echo UDP server that sends back all incoming datagrams prefixed with a UTF8 string. In my attempts to reach this goal, I succeeded in sending back the incoming data, but when I try to prefix this data with the string:…
Damiaan Dufaux
  • 4,427
  • 1
  • 22
  • 33
3
votes
1 answer

Swift-NIO + WebSocket-Kit: Proper Setup/Cleanup in a Mac App

Context I'm developing a Mac app. In this app, I want to run a websocket server. To do this, I'm using Swift NIO and Websocket-Kit. My full setup is below. Question All of the documentation for Websocket-Kit and SwiftNIO is geared towards a creating…
Bryan
  • 4,628
  • 3
  • 36
  • 62
3
votes
2 answers

Chained Throwing Futures in SwiftNIO & Vapor

In Vapor 4, I'm processing a post request by calling a request on a 3rd party API and returning a value based on the result I get back. The following code results in the error: "Invalid conversion from throwing function ... to non-throwing…
GingerBreadMane
  • 2,630
  • 1
  • 30
  • 29
2
votes
0 answers

Calling URL request with private and public key

For Vapor script that runs on Linux I need to make a request that corresponds to following cURL but as of now, I was unable to find the best solution for this. curl -X GET \ https://endpoint \ --cert ./sandbox.pem --key ./sandbox.key PEM is of…
cluelessCoder
  • 948
  • 6
  • 19
2
votes
1 answer

CircularBuffer error after upgrading to Xcode 13.3, SwiftNIO, Vapor in the mix

I have a project that will not compile, after upgrading to Xcode 13.3 The error is Type 'CircularBuffer' does not conform to protocol 'MutableCollection' and Unavailable subscript 'subscript(_:)' was used to satisfy a requirement of…
Dan Donaldson
  • 1,061
  • 1
  • 8
  • 21
2
votes
2 answers

How do I get `Data` objects into Swift-NIO without making copies?

I'm fairly new to Swift and very new to NIO. I'm adding Swift code to a large project that needs to up/down load a lot of data (GBs) to AWS. To that end, I've imported the GitHub project Soto, which relies heavily on NIO. Most methods that…
James Bucanek
  • 3,299
  • 3
  • 14
  • 30
1
2 3 4