# WebSocketRequest Development Started

**URL:** <https://forums.swift.org/t/websocketrequest-development-started/47154>\
**Category:** Alamofire\
**Created:** [April 4, 2021, 9:02pm UTC](https://forums.swift.org/t/websocketrequest-development-started/47154 "2021-04-04T21:02:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [April 4, 2021, 9:02pm UTC](https://forums.swift.org/t/websocketrequest-development-started/47154/1 "2021-04-04T21:02:11Z")

</div>

Alamofire has started development of a `WebSocketRequest` type on the [`feature/websocket-request`](https://github.com/alamofire/alamofire/tree/feature/websocket-request) branch. `WebSocketRequest` wraps `URLSessionWebSocketTask` to provide websocket functionality using Alamofire APIs. We'd like to avoid the mistakes made during `DataStreamRequest`'s developer and start gathering use cases, desired API, and feature requests before fully building out the feature.

Fundamentally, `WebSocketRequest` won't be too different than `DataStreamRequest`, with closure handlers that are called as data is received. The biggest difference, obviously, is the ability to send messages back along the socket.

So we're asking the community to tell use your dream websocket features by providing examples of your use, problems you encounter with other websocket libraries or `URLSessionWebSocketTask`, and features you wish those other libraries had.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 13, 2021, 1:31am UTC](https://forums.swift.org/t/websocketrequest-development-started/47154/2 "2021-06-13T01:31:51Z")

</div>

This wrapper has made good progress and should now be usable to receive `URLSessionWebSocketTask.Message` values, as well as sending messages to the server.

A note of caution: `URLSessionWebSocketTask` seems to have a regression in at least iOS 14.5 / macOS 11.4 where messages received just before a close frame from the server will be dropped. If you control the server, adding a delay before the close frame can workaround the issue. I've found 60ms to be sufficient for local server on a virtualized machine. You should test will real devices for an appropriate delay.

---

<div class="post-metadata">

**Author:** ![ballad](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ballad/32/22156_2.png) [@ballad](https://forums.swift.org/u/ballad)\
**Post date:** [March 30, 2023, 3:44am UTC](https://forums.swift.org/t/websocketrequest-development-started/47154/3 "2023-03-30T03:44:27Z")

</div>

Hi, may I ask what is the current situation regarding the web socket request feature and is there any time plan? Thanks!

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [April 19, 2023, 7:56pm UTC](https://forums.swift.org/t/websocketrequest-development-started/47154/4 "2023-04-19T19:56:47Z")

</div>

There is no timeframe for release. You can use it off the branch but the API may be unstable as I polish and add more tests. It's largely feature complete, though I still need some high level APIs as well as more tests.

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [February 1, 2024, 2:41pm UTC](https://forums.swift.org/t/websocketrequest-development-started/47154/5 "2024-02-01T14:41:12Z")

</div>

`WebSocketRequest` is now available on `master` under an SPI. I hope to finish up the documentation and tests soon so it can go out in the next release.
