             case .closeConn:
                 if let error = finalError {
                     self.event.error(error)
-                    self.eventDelegate?.webSocketError(error as NSError)
+					#if os(Linux)
+						self.eventDelegate?.webSocketError(error._bridgeToNSError())
+					#else
+						self.eventDelegate?.webSocketError(error as NSError)
+					#endif
                 }
                 privateReadyState = .closed
                 if rd != nil {

                reqs += "\(key): \(val)\r\n"
            }
        }
        var keyb = [UInt32](repeating: 0, count: 4)
        for i in 0 ..< 4 {
            keyb[i] = arc4random()
        }
        let rkey = Data(bytes: UnsafePointer(keyb), count: 16).base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
        reqs += "Sec-WebSocket-Key: \(rkey)\r\n"
        reqs += "\r\n"
        var header = [UInt8]()

            wr.setProperty(StreamNetworkServiceTypeValue.voice.rawValue, forKey: Stream.PropertyKey.networkServiceType)
        }
        if allowSelfSignedSSL {
			#if os(Linux)
				fatalError("no self-signed SSL on Linux")
			#else
				let prop: Dictionary<NSObject,NSObject> = [kCFStreamSSLPeerName: kCFNull, kCFStreamSSLValidatesCertificateChain: NSNumber(value: false)]
				rd.setProperty(prop, forKey: Stream.PropertyKey(rawValue: kCFStreamPropertySSLSettings as String as String))
				wr.setProperty(prop, forKey: Stream.PropertyKey(rawValue: kCFStreamPropertySSLSettings as String as String))
			#endif
        }
        rd.delegate = delegate
        wr.delegate = delegate
