# AsyncSequence from URLSessionWebSocketTask?

**URL:** <https://forums.swift.org/t/asyncsequence-from-urlsessionwebsockettask/82858>\
**Category:** Using Swift\
**Tags:** concurrency, websocket, asyncsequence\
**Created:** [October 25, 2025, 1:54pm UTC](https://forums.swift.org/t/asyncsequence-from-urlsessionwebsockettask/82858 "2025-10-25T13:54:05Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![eskimo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/eskimo/32/13558_2.png) [@eskimo](https://forums.swift.org/u/eskimo)\
**Post date:** [October 29, 2025, 8:43am UTC](https://forums.swift.org/t/asyncsequence-from-urlsessionwebsockettask/82858/9 "2025-10-29T08:43:40Z")

</div>

> does Apple actually provide a readily available WebSocket connection?

Yes. It’s very easy to set up if you’re using the latest API:

```swift
let connection = NetworkConnection(to: endpoint) {
    WebSocket {
        TLS() // or TCP()
    }
}

```

See WWDC 2025 Session 250 [Use structured concurrency with Network framework](https://developer.apple.com/videos/play/wwdc2025/250/) for more about that API.

With the original `NWConnection` API it requires a bit more ceremony. See [this forums post](https://developer.apple.com/forums/thread/693799?answerId=695452022#695452022). Oh, and that thread also has code for the original Network framework C API.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

---

_[View the full topic](https://forums.swift.org/t/asyncsequence-from-urlsessionwebsockettask/82858)._
