override fun close() = client?.disconnect()
Return type of 'close' is not a subtype of the return type of the overridden member 'public abstract fun close(): Unit defined in java.lang.AutoCloseable'
Unit? is a supertype of Unit, not a subtype.
So, you have to do:
override fun close() { client?.disconnect() }
... which discards the result of client?.disconnect()
and returns Unit.