Swiftpack.co - Package - vapor/websocket-kit


Stars: 125


Automatic WebSocket pings - 2020-05-01 19:11:40

This patch was authored by @bridger and released by @tanner0101.

Adds a pingInterval property on WebSocket which will trigger automatic pings to the peer to ensure that the connection is still active (#68).

Send correct close code to peer - 2020-05-01 18:53:06

This patch was authored by @bridger and released by @tanner0101.

Updates WebSocket close to send correct code to peer according to RFC6455 (#67).

WebSocketKit 2.0.0 - 2020-03-30 22:47:52

Docs: https://docs.vapor.codes/4.0/websockets/

More information on Vapor 4 official release: https://forums.swift.org/t/vapor-4-official-release-begins/34802

Release Candidate 1 - 2020-03-01 17:21:38

Updates to Swift 5.2 and macOS 10.15. Adds additional CI + README updates.

Release candidates represent the final shift toward focusing on bug fixes and documentation. Breaking changes will only be accepted for critical issues. We expect a final release of this package shortly after Swift 5.2's release date.

Add errorCaught handler to close the WebSocket - 2020-02-26 21:09:32

Now when an error is thrown by NIO we receive it and close the WebSocket connection. The error code is available on WebSocket.closeCode by the time the WebSocket.onClose future resolves (#61, fixes #58).

Add channelInactive callback to mark WebSocket as closed. - 2020-02-26 20:40:00

The channelInactive callback is triggered when a WebSocket closes without sending a close code. Previously, the WebSocket.onClose future was still fulfilled but WebSocket.isClosed would be false and WebSocket.closeCode would be nil. This would later cause an assertion when WebSocket deinitialized. Now the onClose future is still fulfilled, but while also setting isClosed and closeCode (#60, fixes https://github.com/vapor/vapor/issues/2107).

Fix Atomic Deprecation - 2020-01-22 17:50:36

Fixes Atomic deprecation (fixes #53)

wss:// fix - 2020-01-20 17:24:41

Fixes a small issue with regards to forwarding bytes on a wss websocket. Also ups NIO version to 2.11.1 because of https://github.com/apple/swift-nio/pull/1280.

Add ping/pong callbacks to WebSocket - 2019-12-16 22:09:20

  • Adds onPing and onPong callbacks to WebSocket (#45)

Although WebSocketKit handles ping / pong automatically according to spec, it can be useful to know when these events happen.

ws.onPong { ws in
    print("pong received")

ws.onPing { ws in
    print("ping received")
  • Adds WebSocket.closeCode containing WebSocketErrorCode that is set when the WebSocket closes (#45)

  • HTTPHeaders are now passed through WebSocket.connect calls (#45)

WebSocketKit 2.0.0 Beta 2 - 2019-12-09 15:34:58

  • Fixed wss:// default port. (#47, #48)

  • Enabled test discovery on Linux (#50)

WebSocketKit 2.0.0 Beta 1 - 2019-10-24 19:09:58

This package has been renamed to WebSocketKit. It now focuses on supplying a WebSocket client modeled after async-http-client. WebSocket server is still supported, but it is expected that you will bring your own NIO ServerBootstrap.

For usage examples, check out the tests folder: https://github.com/vapor/websocket-kit/blob/master/Tests/WebSocketKitTests/NIOWebSocketClientTests.swift

WebSocket 1.1.2 - 2019-03-26 17:04:16


  • Fixed a reference cycle in WebSocket.

WebSocket 1.1.1 - 2019-01-17 18:16:59


  • WebSocket now buffers incoming messages before callbacks are set. (#31)

WebSocket 1.1.0 - 2018-10-16 18:37:26


  • New send(raw:opcode:fin:promise:) method on WebSocket. (#28)
ws.send(raw: "Hello, ", opcode: .text, fin: false)
ws.send(raw: "world", opcode: .continuation, fin: false)
ws.send(raw: "!", opcode: .continuation)
  • WebSocket server now supports parsing continuation frames from the client. (#27)


  • WebSocket client now properly masks pong frame. (#26)

Websocket 1.0.2 - 2018-09-19 13:00:04

Fixes masking frame issue in client mode. Thanks @pvels

WebSocket 1.0.1 - 2018-05-09 02:40:01


  • Added support for sending / receiving WebSocket close codes (#6, #3).
ws.onCloseCode { closeCode in
ws.close(code: .normalClosure)
  • Max frame size is now configurable for both WebSocket client and server (#7, #4).
  • You can now specify extra headers to add during WebSocket client upgrade (#2).


  • WebSocket.isClosed is now properly set to true when closed (#8, #5).

Milestone: 1.0.1

WebSocket 1.0.0 - 2018-04-18 21:53:00

Introducing WebSocket 1.0 🎉 🔌 Non-blocking, event-driven WebSocket client and server built on Swift NIO.

Docs: https://docs.vapor.codes/3.0/websocket/getting-started/

API Docs: https://api.vapor.codes/websocket/latest/WebSocket/

This module has been moved from the old vapor/engine repo to its own package. This will make it easier to version going forward 🙌.

Milestone: 1.0.0