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

Android PubSub with WebSockets Sample does not work!!! #750

Closed
iwwork opened this issue Feb 28, 2019 · 9 comments
Closed

Android PubSub with WebSockets Sample does not work!!! #750

iwwork opened this issue Feb 28, 2019 · 9 comments
Assignees
Labels
closing soon Issue will auto-close if there is no additional activity within 7 days. iot Issues with the AWS Android SDK for Internet of Things (IoT) pending-maintainer-response Issue is pending response from an Amplify team member question General question

Comments

@iwwork
Copy link

iwwork commented Feb 28, 2019

Thanks @muellerfr @minbi @desokroshan to solve this one:
AndroidPubSub Sample does not work!!!
#719

Now I tried to follow the above method to use it in the following:
AndroidPubSubWebSocket
https://github.com/awslabs/aws-sdk-android-samples/tree/master/AndroidPubSubWebSocket
there still has some problems:

State your question
The apk keeps reconnceting

Which AWS Services are you utilizing?
AWS IoT

Provide code snippets (if applicable)

Followed the instruction https://github.com/awslabs/aws-sdk-android-samples/tree/master/AndroidPubSubWebSocket to set the parameter on the AWS cloud

Downloaded the whole code from https://github.com/awslabs/aws-sdk-android-samples

Used Android Studio 3.3.1 to open the folder AndroidPubSubWebSocket
I change in the awsconfiguration.json
"PoolId": "REPLACE_ME",
"Region": "us-east-1"

PubSubActivity.java
// Customer specific IoT endpoint
// AWS Iot CLI describe-endpoint call returns: XXXXXXXXXX.iot..amazonaws.com,
private static final String CUSTOMER_SPECIFIC_IOT_ENDPOINT = "REPLACE_ME";

add implementation "com.amazonaws:aws-android-sdk-auth-userpools:$aws_version in AndroidPubSub/build.gradle

Sync, Build and Run App on emulator9.0 or Mobile Phone8.0, the result in Logcat is

com.amazonaws.demo.androidpubsubwebsocket D/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: clientId = ***
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: MQTT broker: ***:443
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: Inspecting user state details
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: waitForSignIn: userState:GUEST
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: ready to do mqtt connect
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: metrics collection is enabled, username: ?SDK=Android&Version=2.12.1
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: resetting reconnect attempt and retry time
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: Setting up Callback for MqttClient
com.amazonaws.demo.androidpubsubwebsocket D/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Status = Connecting
com.amazonaws.demo.androidpubsubwebsocket D/NetworkSecurityConfig: No Network Security Config specified, using platform default
com.amazonaws.demo.androidpubsubwebsocket W/AWSIotMqttManager: onFailure: connection failed.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 
com.amazonaws.demo.androidpubsubwebsocket D/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Status = Reconnecting
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: schedule Reconnect attempt 0 of 10 in 4 seconds.
com.amazonaws.demo.androidpubsubwebsocket E/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: TID: 5505 trying to reconnect to session
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: attempting to reconnect to mqtt broker
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: Inspecting user state details
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: waitForSignIn: userState:GUEST
/com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: Reconnect to mqtt broker: *** mqttWebSocketURL: wss://***:443/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=***
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: Setting up Callback for MqttClient
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: mqtt reconnecting attempt 1
com.amazonaws.demo.androidpubsubwebsocket W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: schedule Reconnect attempt 1 of 10 in 8 seconds.
com.amazonaws.demo.androidpubsubwebsocket D/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Status = Reconnecting
com.amazonaws.demo.androidpubsubwebsocket E/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 

The Apk keeps reconnectiong.

How to deal with this problem?
Should there some other code be added?

Environment(please complete the following information):

  • SDK Version: [e.g. 2.6.25]

Device Information (please complete the following information):

  • Device: [e.g. Pixel XL, Simulator]
  • Android Version: [e.g. Nougat 7.1.2]
  • Specific to simulators:

If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.

@desokroshan desokroshan self-assigned this Feb 28, 2019
@desokroshan desokroshan added iot Issues with the AWS Android SDK for Internet of Things (IoT) question General question labels Feb 28, 2019
@desokroshan
Copy link
Contributor

@iwwork Thank you for reporting this. I will try to follow the steps and reproduce the issue. The stack trace indicates that the WebSocket handshake request for upgrade failed. Can you please let us know if you are using the default version of paho or are you using a custom version. If you are not sure about the paho version, chances are you are using the default version. Please let us know accordingly.

@desokroshan desokroshan added the pending-community-response Issue is pending response from the issue requestor label Feb 28, 2019
@iwwork
Copy link
Author

iwwork commented Mar 1, 2019

@desokroshan Thanks.
As for the paho version, I am not sure. Just exactly following the default instructions of aws iot, cognito, and the android apk, which on the official website you provide.

@iwwork
Copy link
Author

iwwork commented Mar 5, 2019

@muellerfr @desokroshan please help, wish to solve it asap

@desokroshan
Copy link
Contributor

@iwwork I am unable to reproduce the issue on my end. The error suggests that the handshake request for upgrading connection to websocket failed. Can you please confirm the following :

  1. You have enabled access to unauthenticated identities for your identity pool?
  2. AWSIoTFullAccess policy is attached to the unauthenticated role for the userpool?
  3. Can you share the request-id returned by AWS IoT, so I can look up why the handshake request for upgrade was rejected by IoT?

@iwwork
Copy link
Author

iwwork commented Mar 6, 2019

@desokroshan Thanks
The first 2 points are ok, as it was successful with android pubsub.
as for the request-id, not sure what it was.
Just paste all the feedback from the logcat of android studio as below.
And the paho mqtt version seemed to be v3.

Wish these could solve it.

com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: TID: 5385 trying to reconnect to session
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: attempting to reconnect to mqtt broker
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: Inspecting user state details
com.amazonaws.demo.androidpubsubwebsocket D/AWSMobileClient: waitForSignIn: userState:GUEST
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: Reconnect to mqtt broker: x----.amazonaws.com mqttWebSocketURL: wss://
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: Setting up Callback for MqttClient
com.amazonaws.demo.androidpubsubwebsocket D/AWSIotMqttManager: mqtt reconnecting attempt 3
com.amazonaws.demo.androidpubsubwebsocket W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 
com.amazonaws.demo.androidpubsubwebsocket I/AWSIotMqttManager: schedule Reconnect attempt 3 of 10 in 32 seconds.
com.amazonaws.demo.androidpubsubwebsocket D/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Status = Reconnecting
com.amazonaws.demo.androidpubsubwebsocket E/com.amazonaws.demo.androidpubsubwebsocket.PubSubActivity: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:764) 

@frankmuellr frankmuellr removed the pending-community-response Issue is pending response from the issue requestor label Mar 11, 2019
@desokroshan
Copy link
Contributor

@iwwork Thanks for sharing the stack trace. Request-id is not available in the stack trace. You will have to setup a debugger add breakpoints where you receive response from iot or lower your log-level. But before that, since I am not able to reproduce it on my end, I am guessing the exception might be related to the specific android version you are using. Can you please share the details of the device and Android API level you are running the sample on. Also can you try running it on API Level 28 and let me know if the error persists.

@desokroshan desokroshan added pending-community-response Issue is pending response from the issue requestor closing soon Issue will auto-close if there is no additional activity within 7 days. labels Mar 14, 2019
@stale
Copy link

stale bot commented Mar 27, 2019

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Mar 27, 2019
@alianikaydin
Copy link

I have encountered with the same error on version 8.1 and 6.0 Android devices and I'm using awsIOTAndroidSDK version 2.12.6. Here is my log record.

04-05 17:51:20.442 29110-29110/com.smarthome.core.main I/AWSKeyValueStore: Detected Android API Level = 23
04-05 17:51:20.443 29110-29110/com.smarthome.core.main I/AWSKeyValueStore: Using keyAlias = com.amazonaws.android.auth.aesKeyStoreAlias
04-05 17:51:20.456 29110-29110/com.smarthome.core.main I/AWSKeyValueStore: Creating the AWSKeyValueStore with key for sharedPreferences = com.amazonaws.android.auth
04-05 17:51:20.463 29110-29110/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Loading credentials from SharedPreferences
04-05 17:51:20.699 29110-29110/com.smarthome.core.main V/BoostFramework: mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
04-05 17:51:20.699 29110-29110/com.smarthome.core.main V/BoostFramework: mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
04-05 17:51:20.699 29110-29110/com.smarthome.core.main V/BoostFramework: mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
04-05 17:51:20.699 29110-29110/com.smarthome.core.main V/BoostFramework: mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String)
04-05 17:51:20.699 29110-29110/com.smarthome.core.main V/BoostFramework: mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop()
04-05 17:51:20.701 29110-29110/com.smarthome.core.main V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b079672
04-05 17:51:20.702 29110-29110/com.smarthome.core.main V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@3dfac3
04-05 17:51:20.743 29110-29110/com.smarthome.core.main V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@7344935
04-05 17:51:20.744 29110-29110/com.smarthome.core.main V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@38f81ca
04-05 17:51:20.821 29110-29222/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Making a network call to fetch credentials.
04-05 17:51:21.386 29110-29222/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
04-05 17:51:21.764 29110-29222/com.smarthome.core.main I/AWSIotMqttManager: metrics collection is enabled, username: ?SDK=Android&Version=2.12.6
04-05 17:51:21.765 29110-29222/com.smarthome.core.main I/AWSIotMqttManager: resetting reconnect attempt and retry time
04-05 17:51:21.765 29110-29222/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Client Connecting.
04-05 17:51:21.766 29110-29222/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Connecting
04-05 17:51:22.599 29110-29236/com.smarthome.core.main W/AWSIotMqttManager: onFailure: connection failed.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:22.600 29110-29236/com.smarthome.core.main E/com.smarthome.core.main.cloud.aws.AWSIOTService: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:22.600 29110-29236/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Reconnecting.
04-05 17:51:22.600 29110-29236/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Reconnecting
04-05 17:51:22.601 29110-29236/com.smarthome.core.main I/AWSIotMqttManager: schedule Reconnect attempt 0 of 10 in 4 seconds.
04-05 17:51:26.608 29110-29237/com.smarthome.core.main I/AWSIotMqttManager: attempting to reconnect to mqtt broker
04-05 17:51:26.608 29110-29237/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Making a network call to fetch credentials.
04-05 17:51:26.754 29110-29237/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
04-05 17:51:27.497 29110-29247/com.smarthome.core.main W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:27.497 29110-29247/com.smarthome.core.main I/AWSIotMqttManager: schedule Reconnect attempt 1 of 10 in 8 seconds.
04-05 17:51:27.500 29110-29247/com.smarthome.core.main E/com.smarthome.core.main.cloud.aws.AWSIOTService: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:27.500 29110-29247/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Reconnecting.
04-05 17:51:27.500 29110-29247/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Reconnecting
04-05 17:51:35.508 29110-29248/com.smarthome.core.main I/AWSIotMqttManager: attempting to reconnect to mqtt broker
04-05 17:51:35.508 29110-29248/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Making a network call to fetch credentials.
04-05 17:51:35.683 29110-29248/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
04-05 17:51:36.565 29110-29256/com.smarthome.core.main W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:36.566 29110-29256/com.smarthome.core.main I/AWSIotMqttManager: schedule Reconnect attempt 2 of 10 in 16 seconds.
04-05 17:51:36.569 29110-29256/com.smarthome.core.main E/com.smarthome.core.main.cloud.aws.AWSIOTService: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:36.569 29110-29256/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Reconnecting.
04-05 17:51:36.569 29110-29256/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Reconnecting
04-05 17:51:52.585 29110-29257/com.smarthome.core.main I/AWSIotMqttManager: attempting to reconnect to mqtt broker
04-05 17:51:52.586 29110-29257/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Making a network call to fetch credentials.
04-05 17:51:52.736 29110-29257/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
04-05 17:51:53.525 29110-29267/com.smarthome.core.main W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:53.525 29110-29267/com.smarthome.core.main I/AWSIotMqttManager: schedule Reconnect attempt 3 of 10 in 32 seconds.
04-05 17:51:53.528 29110-29267/com.smarthome.core.main E/com.smarthome.core.main.cloud.aws.AWSIOTService: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:51:53.528 29110-29267/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Reconnecting.
04-05 17:51:53.529 29110-29267/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Reconnecting
04-05 17:52:25.561 29110-29268/com.smarthome.core.main I/AWSIotMqttManager: attempting to reconnect to mqtt broker
04-05 17:52:25.561 29110-29268/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Making a network call to fetch credentials.
04-05 17:52:25.717 29110-29268/com.smarthome.core.main D/CognitoCachingCredentialsProvider: Saving credentials to SharedPreferences
04-05 17:52:25.829 29110-29120/com.smarthome.core.main I/art: Background partial concurrent mark sweep GC freed 96523(5MB) AllocSpace objects, 27(1252KB) LOS objects, 35% free, 28MB/44MB, paused 995us total 103.875ms
04-05 17:52:26.566 29110-29288/com.smarthome.core.main W/AWSIotMqttManager: Reconnect failed 
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:52:26.566 29110-29288/com.smarthome.core.main I/AWSIotMqttManager: schedule Reconnect attempt 4 of 10 in 64 seconds.
04-05 17:52:26.568 29110-29288/com.smarthome.core.main E/com.smarthome.core.main.cloud.aws.AWSIOTService: Connection error.
    MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.receiveHandshakeResponse(WebSocketHandshake.java:133)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketHandshake.execute(WebSocketHandshake.java:74)
        at org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule.start(WebSocketSecureNetworkModule.java:77)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
        at java.lang.Thread.run(Thread.java:818) 
04-05 17:52:26.568 29110-29288/com.smarthome.core.main D/com.smarthome.core.main.cloud.aws.AWSIOTService: Reconnecting.
04-05 17:52:26.569 29110-29288/com.smarthome.core.main D/DashboardPresenter: accept: connectionAction:Reconnecting

@tonytonchev
Copy link

same error still happens, using the amazon sample code in AndroidPubSubWebSocket. This app is removed now from the github samples with android SDK, so I guess it's not fixable?

@github-actions github-actions bot added pending-maintainer-response Issue is pending response from an Amplify team member and removed pending-community-response Issue is pending response from the issue requestor labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing soon Issue will auto-close if there is no additional activity within 7 days. iot Issues with the AWS Android SDK for Internet of Things (IoT) pending-maintainer-response Issue is pending response from an Amplify team member question General question
Projects
None yet
Development

No branches or pull requests

5 participants