 			case Stream.Event.openCompleted:
 				handleOpenning()
 			case Stream.Event.errorOccurred:
-				handleError(error: stream.streamError!)
+				disconnect(withError: stream.streamError)
 			case Stream.Event.hasBytesAvailable:
 				let data = inputStream!.readAllData()
 				delegateQueue?.async {

			case Stream.Event.openCompleted:
				handleOpenning()
			case Stream.Event.errorOccurred:
				handleError(error: stream.streamError!)
			default: break
		}
	}

		delegateQueue?.async {
			self.delegate?.socketDidConnect(self)
		}
	}
	
	private func setupSocketsSecurity() {
