You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My app is connected to AWS IoT using aws-android-sdk-core and aws-android-sdk-iot. I am using hivemq-mqtt-client for the client side. However, when using minSdkVersion lower than 26(in my case it is 19), I am unable to connect over IOT. It is working fine if set to minsdkversion 26
🔬 How To Reproduce
Steps to reproduce the behavior:
1 I have attached sample code to reproduce the issue
// id ("com.google.gms.google-services")
id ("kotlin-kapt")
// id ("com.google.firebase.crashlytics")
id("com.apollographql.apollo3") version "4.0.0-alpha.1"
id("com.github.sgtsilvio.gradle.android-retrofix") version "0.5.0"
}
retrofix("net.sourceforge.streamsupport:android-retrostreams:1.7.4") // for backporting streams
retrofix("net.sourceforge.streamsupport:android-retrofuture:1.7.4") // for backporting future
retrofix("org.threeten:threetenbp:1.6.5") // for backporting time
implementation 'com.hivemq:hivemq-mqtt-client:1.3.0'
}
(2) client code to connect over IOT
fun createClient(
clientKey: String,
clientId: String,
brokerUrl: String,
privateKey: String
): Mqtt5AsyncClient? {
val keyManagerFactory: KeyManagerFactory = createKeyManagerFactory(privateKey)
val trustManagerFactory: TrustManagerFactory = createTrustManagerFactory(clientKey)
return MqttClient.builder()
.useMqttVersion5()
.identifier(clientId)
.serverHost(brokerUrl)
.serverPort(443)
.sslConfig().protocols(Arrays.asList("TLSv1.2"))
.keyManagerFactory(keyManagerFactory)
.trustManagerFactory(trustManagerFactory)
.applySslConfig()
.buildAsync()
}
fun createKeyManagerFactory(privateKey: String): KeyManagerFactory {
try {
val keyStoreTemp = keystore
// val keyInputStream = ByteArrayInputStream(privateKey.toByteArray())
// keyStoreTemp.load(keyInputStream, null)
val keyManagerFactory: KeyManagerFactory =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
keyManagerFactory.init(keyStoreTemp,"password".toCharArray())
return keyManagerFactory
} catch (e: java.lang.Exception) {
e.printStackTrace()
throw IllegalArgumentException(
"Failed to create KeyManagerFactory for MQTT Client connection.",
e
)
}
}
fun createTrustManagerFactory(certificate: String): TrustManagerFactory {
try {
val keyStoreTemp = keystore
// val certInputStream = ByteArrayInputStream(certificate.toByteArray())
// keyStore.load(certInputStream, null)
val trustManagerFactory: TrustManagerFactory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
trustManagerFactory.init(keyStoreTemp)
return trustManagerFactory
} catch (e: java.lang.Exception) {
e.printStackTrace()
throw IllegalArgumentException(
"Failed to create TrustManagerFactory for MQTT Client connection.",
e
)
}
}
JVM version?
compileOptions {
// Support for Java 8 features
// coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Operating System?
Android kitkat 4.4
MAC os
Which MQTT protocol version is being used?
Mqtt5AsyncClient
Which MQTT broker (name and version)?
Please check gradle code and client code
Screenshots
The text was updated successfully, but these errors were encountered:
🐛 Bug Report
My app is connected to AWS IoT using aws-android-sdk-core and aws-android-sdk-iot. I am using hivemq-mqtt-client for the client side. However, when using minSdkVersion lower than 26(in my case it is 19), I am unable to connect over IOT. It is working fine if set to minsdkversion 26
🔬 How To Reproduce
Steps to reproduce the behavior:
1 I have attached sample code to reproduce the issue
Code sample
(1) here is the gradle file
// id ("com.google.gms.google-services")
id ("kotlin-kapt")
// id ("com.google.firebase.crashlytics")
id("com.apollographql.apollo3") version "4.0.0-alpha.1"
id("com.github.sgtsilvio.gradle.android-retrofix") version "0.5.0"
}
android {
namespace 'com.eprintitsaas.avision.app'
compileSdk 33
// coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
resources {
excludes += ['META-INF/INDEX.LIST', 'META-INF/io.netty.versions.properties']
}
}
kotlinOptions {
jvmTarget = '1.8'
}
apollo {
service("service") {
packageName.set("com.eprintitsaas.avision.app")
}
}
}
dependencies {
implementation(files("libs/commons.jar"))
implementation files('libs/WorkpathLib.aar')
implementation files('libs/WorkpathLib-javadoc.jar')
// implementation 'androidx.core:core-ktx:1.11.0-beta02'
// implementation 'androidx.appcompat:appcompat:1.6.1'
// implementation 'com.google.android.material:material:1.9.0'
// implementation("com.squareup.okhttp3:logging-interceptor:3.0.0-RC1")
// implementation ("com.squareup.okhttp3:okhttp:4.9.1"){
// force = true //API 19 support
// }
implementation("com.squareup.retrofit2:converter-scalars:2.6.4")
// implementation ("com.squareup.okhttp3:okhttp:3.12.13"){
// force = true //API 19 support
// }
// implementation 'com.amazonaws:aws-android-sdk-iot:2.73.0'
// implementation 'com.amazonaws:aws-android-sdk-core:2.73.0'
// coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.3'
// coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
// implementation 'org.conscrypt:conscrypt-android:2.5.2'
}
(2) client code to connect over IOT
// val keyInputStream = ByteArrayInputStream(privateKey.toByteArray())
// keyStoreTemp.load(keyInputStream, null)
val keyManagerFactory: KeyManagerFactory =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
keyManagerFactory.init(keyStoreTemp,"password".toCharArray())
return keyManagerFactory
} catch (e: java.lang.Exception) {
e.printStackTrace()
throw IllegalArgumentException(
"Failed to create KeyManagerFactory for MQTT Client connection.",
e
)
}
}
// val certInputStream = ByteArrayInputStream(certificate.toByteArray())
// keyStore.load(certInputStream, null)
val trustManagerFactory: TrustManagerFactory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
trustManagerFactory.init(keyStoreTemp)
return trustManagerFactory
} catch (e: java.lang.Exception) {
e.printStackTrace()
throw IllegalArgumentException(
"Failed to create TrustManagerFactory for MQTT Client connection.",
e
)
}
}
Environment
Where are you running/using this client?
Android studio emulator Nexus 5 API 19
What version of this client are you using?
implementation 'com.hivemq:hivemq-mqtt-client:1.3.0'
JVM version?
compileOptions {
// Support for Java 8 features
// coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Operating System?
Android kitkat 4.4
MAC os
Which MQTT protocol version is being used?
Mqtt5AsyncClient
Which MQTT broker (name and version)?
Please check gradle code and client code
Screenshots
The text was updated successfully, but these errors were encountered: