aws-sdk-android icon indicating copy to clipboard operation
aws-sdk-android copied to clipboard

How to disable the IPv6 address?

Open chance-yang opened this issue 1 year ago • 1 comments

We have many customers whose networks do not support IPV6. Is there a way to set up the MQTT connection to use only IPV4?

code snippets

// MQTT Client
            if (mqttManager == null) {
                mqttManager = new AWSIotMqttManager(mClientId, mEndPoint);
                // Set keepalive to 10 seconds.  Will recognize disconnects more quickly but will also send
                // MQTT pings every 10 seconds.
                int keepAlive = connectConfig.getKeepAlive();
                mqttManager.setKeepAlive(keepAlive);
                int minReconnectRetryTime = connectConfig.getMinReconnectRetryTime();
                int maxReconnectRetryTime = connectConfig.getMaxReconnectRetryTime();
                if (minReconnectRetryTime <= 0) {
                    minReconnectRetryTime = (int) (keepAlive * 1.5) + 1;
                }
                if (maxReconnectRetryTime <= 0 || minReconnectRetryTime >= maxReconnectRetryTime) {
                    maxReconnectRetryTime = minReconnectRetryTime + 120;
                }
                mqttManager.setReconnectRetryLimits(minReconnectRetryTime,
                        maxReconnectRetryTime);
                mqttManager.setAutoReconnect(true);
                mqttManager.setCleanSession(false);
                mqttManager.setMaxAutoReconnectAttempts(connectConfig.getMaxAutoReconnectAttempts());
            }
            String keyStoreName = Utils.getMd5Value(mClientId + mEndPoint);
            
            KeyStore clientKeyStore = getClientKeyStore(context, keyStoreName, certificatePemId, privatePemId);
            isConnecting = true;
            int portNumber = connectConfig.getPortNumber();
            if (portNumber == 443) {
                mqttManager.connectUsingALPN(clientKeyStore, new MqttClientCallback());
            } else {
                mqttManager.connect(clientKeyStore, new MqttClientCallback());
            }

Environment(please complete the following information):

  • implementation 'com.amazonaws:aws-android-sdk-iot:2.64.0'
  • implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.64.0'

chance-yang avatar Nov 07 '23 11:11 chance-yang

Hi @chance-yang Please see this thread (https://github.com/aws-amplify/aws-sdk-android/issues/2105) to see if any solutions are able to fit your use case.

tylerjroach avatar Nov 17 '23 18:11 tylerjroach

@chance-yang Were you unable to find a solution? Is this still an issue for you?

phantumcode avatar Jul 26 '24 14:07 phantumcode