IOException while requesting key: Invalid device key response

pir8ped picture pir8ped · May 4, 2018 · Viewed 8.6k times · Source

I'm using a Pi 3 with google IOT to operate some relays that control valves on an irrigation system. The system uses the internet to get a weather forecast to work how much water to use, and uses NanoHTTPD to provide a UI.

It's running nicely, but occasionally I get an error which stops the whole thing. From the log files:

05-04 05:26:14.677 737-1077/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout:
05-04 05:26:14.678 737-1077/com.google.android.gms.persistent W/Conscrypt:    java.lang.reflect.Method.invoke(Native Method)
       com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11973330:13)
05-04 05:26:14.798 737-1077/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout:
05-04 05:26:14.799 737-1077/com.google.android.gms.persistent W/Conscrypt:    java.lang.reflect.Method.invoke(Native Method)
       com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11973330:13)
05-04 05:26:14.914 737-1077/com.google.android.gms.persistent W/GLSUser: [AppCertManager] IOException while requesting key: 
    java.io.IOException: Invalid device key response.
        at fmk.a(:com.google.android.gms@11973330:12)
        at fmk.a(:com.google.android.gms@11973330:64)
        at fmi.a(:com.google.android.gms@11973330:8)
        at fme.a(:com.google.android.gms@11973330:1)
        at fmd.a(:com.google.android.gms@11973330:10)
        at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms@11973330:7)
        at ers.call(:com.google.android.gms@11973330:3)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at kfr.run(:com.google.android.gms@11973330:26)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at kku.run(Unknown Source:7)
        at java.lang.Thread.run(Thread.java:764)

I'd appreciate some hint on how to stop this from happening.

Thanks.

Answer

Dennis Murage picture Dennis Murage · Jan 26, 2019

Simple. This means that the key on the Google Console that is associated with the IOT service is not matching the one stored locally on your Mac/Pi 3.

Just run: keytool -list -v -keystore <your keystore> -storepass <your store password> and copy the key under SHA1 or SHA256 to the Google Console.

You can create a keystore if none is present by keytool -genkeypair.

For other useful commands run keytool -h.