Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MqttClient connect fails with ConnectionFailedException: protocol TLSv1.2 not supported on Android 4.4.2 #423

Closed
rohit5ram opened this issue Jun 3, 2020 · 3 comments

Comments

@rohit5ram
Copy link

Expected behavior

Mqtt5Client should connect with specified protocol version

Actual behavior

com.hivemq.client.mqtt.exceptions.ConnectionFailedException: java.lang.IllegalArgumentException: Protocol TLSv1.2 is not supported.

To Reproduce

Steps

mqttClientBuilder.sslConfig()
.protocols(Collections.singletonList(TlsVersion.TLS_1_2.javaName()))
.applySslConfig()
.buildAsync();

Reproducer code

Mqtt5ClientBuilder mqttClientBuilder = MqttClient.builder()
.useMqttVersion5()
.identifier(deviceId)
.serverHost(appContext.getString(R.string.mqtt_wss_broker))
.serverPort(443)
.webSocketConfig(MqttWebSocketConfig.builder().serverPath("mqtt").build())
.automaticReconnectWithDefaultConfig()
.addConnectedListener(context -> {
setMqttClientConnected(true);
Log.i(Util.TAG, LOG_LABEL + " Mqtt client connected");
publishOnline(appContext);
})
.addDisconnectedListener(context -> {
setMqttClientConnected(false);
Log.e(Util.TAG, LOG_LABEL + " Mqtt client disconnected");
LogUtils.logException(new Exception(context.getCause()), LOG_LABEL);
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mqttClientBuilder = mqttClientBuilder.sslWithDefaultConfig();
} else {
mqttClientBuilder = mqttClientBuilder.sslConfig()
.protocols(Collections.singletonList(TlsVersion.TLS_1_2.javaName()))
.applySslConfig();
}
mqttClient = mqttClientBuilder.buildAsync();

Details

  • Affected HiveMQ MQTT Client version(s): 1.2.0
  • Used JVM version: Java 1.8
  • Used OS (name and version): Android 4.4.2
  • Used MQTT version: mqtt5
  • Used MQTT broker (name and version): vernemq
@rohit5ram
Copy link
Author

@SgtSilvio Can you please help us fix this? We are blocked to deploy MQTT support on Android 4.4.2 and lower
We have found a working solution to enable TLSv1.2 by using Google ProviderInstaller
We cannot guarantee to have GooglePlayServices installed on every device. So we cannot rely on it.

We have found another solution to enable TLSv1.2 on OkHttpClient but that wouldn't help us enabling the same on hivemqclient

@SgtSilvio
Copy link
Member

Please ask this question on the HiveMQ Community Forum (https://community.hivemq.com/) as this is not directly related with the HiveMQ MQTT client and you might find help from other people there.

@SgtSilvio
Copy link
Member

As there was no activity anymore, I will close this issue.
Don't hesitate to comment or open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants