         - parameter terminationHandler: Called when the middleware is done. Does not mean that all encoding is done.
     */
     public func setupMiddleware(_ middleware: Process, terminationHandler: (() -> ())?) {
+        DefaultDiscordLogger.Logger.debug("Setting up middleware", type: logType)
+
         encoder.middleware = DiscordEncoderMiddleware(encoder: encoder,
                                                       middleware: middleware,
                                                       terminationHandler: terminationHandler)

        let base = voiceServerInformation.endpoint.components(separatedBy: ":")[0]
        let udpEndpoint = InternetAddress(hostname: base, port: UInt16(udpPort))

        guard let client = try? UDPInternetSocket(address: udpEndpoint) else {
            disconnect()


    // currently only xsalsa20_poly1305 is supported
    // After this point we are good to go in sending encrypted voice packets
    private func selectProtocol(with ip: String, on port: Int) {
        DefaultDiscordLogger.Logger.debug("Selecting UDP protocol with ip: \(ip) on port: \(port)", type: logType)

        let payloadData: [String: Any] = [
            "protocol": "udp",
