Comments (4)
Sorry I missed the broker part. I have replicated your exact setup with the same code. Then I run it on an Android 14 emulator.
I used this command to forward the port from the host PC to the emulator: .\adb.exe forward tcp:1883 tcp:1883
And then I use MQTT X to connect and it works.
Please check again and make sure that the client is setup to use TLS, because I get that same error when I try to connect with MQTT X (the client) with TLS disabled.
from kmqtt.
Hello, this usually happens if you are trying to connect to the broker port where there is no TLS setup. Please check that.
Also can you please post the MQTTClient constructor without sensitive information?
Can you reproduce the problem on a public broker like test.mosquitto.org so that I can try it?
Which version of Android are you running on, are you on an emulator and if yes which device?
from kmqtt.
This issue is when I am using the kmqtt-broker library. I haven't tried the client library yet. I used the kmqtt-broker lib to create my own standalone broker, which works fine when there is no TLS enabled. But when I enable TLS, the broker.listen()
throws the mentioned exception.
Android version - 13 & 14 (Tiramisu and UpsideDown cake)
broker constructor
broker = Broker(
tlsSettings = if (isTlsEnabled) TLSSettings(keyStoreFilePath = getTlsFilepath(), keyStorePassword = "P@ss")else null,
authentication = if (authenticationNeeded) {
object : Authentication {
override fun authenticate(
clientId: String,
username: String?,
password: UByteArray?
): Boolean {
return username == mqttUserName && password?.toByteArray()
?.decodeToString() == mqttPassword
}
}
} else null,
connectionCallbacks = connectionCallbacks, bytesMetrics = bytesMetrics,
)
broker.listen()
private fun getTlsFilepath(): String {
val inputStream = application.resources.openRawResource(R.raw.mqtt_test_cert)
val file = File.createTempFile("keyStore", ".p12", application.cacheDir)
val outputStream = FileOutputStream(file)
inputStream.use { input ->
outputStream.use { output ->
input.copyTo(output)
}
}
Timber.d("File path is ${file.absolutePath}")
return file.absolutePath
}
from kmqtt.
Thank you! Client wasn't set up properly, fixed it and it's working.
from kmqtt.
Related Issues (20)
- iOSBuild failed with Could not find 'openssl-its-simulator-arm64' HOT 2
- ssl server certificate not found (IOS only) HOT 4
- Connecting to a home broker with TCP_PORT & MQTT_PORT HOT 4
- Source and JavaDoc missing from JVM artifacts HOT 1
- Error in recv: 9 on disconnect() HOT 12
- java.nio.BufferOverflowException when calling HOT 6
- Is it possible to add a path in MqttClient? HOT 2
- Provide the Client ID inside MQTTDisconnect HOT 2
- Expose the list of the connected client IDs HOT 5
- Delay in receiving published messages HOT 5
- TLSClientSettings from String instead of file path HOT 6
- Socket connection error on windows native HOT 1
- Delay in Publishing message HOT 2
- Can the broker host address be changed HOT 3
- new feature: [MQTTClient] add the timeout connection in parameters HOT 7
- Feature request: Use cklib to package openssl klibs HOT 1
- Ability to subscribe after broker connected HOT 2
- KMQTT Broker: Any way to know if the broker has been started or stopped adter broker.listen() or broker.stop() gets executed? Something like a listener ?? HOT 3
- Auto reconnect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kmqtt.