github vapor/vapor 4.0.0-beta.4.2
Improve error handling and timeouts for WebSockets

latest releases: 4.97.0, 4.96.0, 4.95.0...
pre-release4 years ago

Improves error handling on WebSocket connections. Improvements to WebSocket-Kit intercept errors or timeouts at the ChannelHandler level and expose them to the WebSocket class.

Now, when an error occurs (such as a malformed WebSocket frame) the error is available via the closeCode on WebSocket. Example:

func connected(request: Request, connection: WebSocket) {
  _ = connection.onClose.always { (result) in
      let closeReason = connectionInfo.connection.closeCode ?? .unknown(0)
      // Application-specific cleanup code here
  }

}

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

Don't miss a new vapor release

NewReleases is sending notifications on new releases.