Closed alvinsee closed 9 years ago
Can you set the string resource http_log_level
to FULL
and try to replicate this? That will give us complete HTTP logging, which will give us a much better idea about what's happening here.
Also, once you've captured the logs, you'll want to put them on Google Drive/Dropbox/etc and share the link with me privately (jens dot knutson at google's email service dot com) or if you want to just post them here, at least remove the "Authorization" header, since that has your auth token.
I've done the above, but the logs arent printing.
.setLogLevel(LogLevel.valueOf(ctx.getString(R.string.http_log_level))) .setLog(new RestAdapter.Log() { @Override public void log(String msg) { Log.d("Retrofit", msg); } });
above is the change I made to RestAdapter.Builder buildCommonRestAdapterBuilder().
Thanks
That's interesting... I'll have to double-check re: the log setting with resources.
Anyway, I'd try this:
.setLog()
call.setLogLevel()
, try just doing: .setLogLevel(LogLevel.FULL)
directlyThat should definitely give you log output.
I've attempted the above yesterday, but to no avail.
D/SparkCloud﹕ Initializing SparkCloud instance D/SparkAccessToken﹕ Scheduling token expiration for Thu Oct 15 09:41:00 PDT 2015 (7773582585ms. D/SoftAPConfigRemover﹕ loadSSIDStringSetWithKey(KEY_SOFT_AP_SSIDS) D/SoftAPConfigRemover﹕ Loaded saved SSIDS: [] D/SoftAPConfigRemover﹕ Returning SSIDS: [] D/SoftAPConfigRemover﹕ saveSSIDsWithKey() KEY_SOFT_AP_SSIDS, [] D/SoftAPConfigRemover﹕ reenableWifiNetworks() D/SoftAPConfigRemover﹕ loadSSIDStringSetWithKey(KEY_DISABLED_WIFI_SSIDS) D/SoftAPConfigRemover﹕ Loaded saved SSIDS: [] D/SoftAPConfigRemover﹕ Returning SSIDS: [] D/SoftAPConfigRemover﹕ saveSSIDsWithKey() KEY_DISABLED_WIFI_SSIDS, [] I/GetReadyActivity﹕ GetReadyActivity.onStart() D/SoftAPConfigRemover﹕ loadSSIDStringSetWithKey(KEY_SOFT_AP_SSIDS) D/SoftAPConfigRemover﹕ Loaded saved SSIDS: [] D/SoftAPConfigRemover﹕ Returning SSIDS: [] D/SoftAPConfigRemover﹕ saveSSIDsWithKey() KEY_SOFT_AP_SSIDS, [] D/SoftAPConfigRemover﹕ reenableWifiNetworks() D/SoftAPConfigRemover﹕ loadSSIDStringSetWithKey(KEY_DISABLED_WIFI_SSIDS) D/SoftAPConfigRemover﹕ Loaded saved SSIDS: [] D/SoftAPConfigRemover﹕ Returning SSIDS: [] D/SoftAPConfigRemover﹕ saveSSIDsWithKey() KEY_DISABLED_WIFI_SSIDS, [] E/Async﹕ Error calling API: Unknown error communicating with server. io.particle.android.sdk.cloud.SparkCloudException at io.particle.android.sdk.cloud.SparkCloud.generateClaimCode(SparkCloud.java:341) at io.particle.android.sdk.devicesetup.ui.GetReadyActivity$3.callApi(GetReadyActivity.java:104) at io.particle.android.sdk.devicesetup.ui.GetReadyActivity$3.callApi(GetReadyActivity.java:101) at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:104) at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:70) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) D/GetReadyActivity﹕ Generating claim code failed
The above is the only logs I'm seeing.
Strange, I'm still not seeing any logging from OkHttp/Retrofit.
Thanks for posting the logs you have, though -- I'm looking into this now.
OK, looking at the source, it's dying right at the retrofit call, and should be an IOException
, which suggests maybe it's not even connecting to the cloud.
If you uninstall/reinstall the app you're working on (to clear any stored app data), does calling SparkCloud.logIn()
work correctly?
yes SparkCloud.logIn() works correctly.
Also, re: logging, are you consuming the Cloud SDK via a gradle dependency or did you pull the source?
If it's the latter, can you try via the gradle dependency? (i.e.: adding compile 'io.particle:cloudsdk:0.1.2'
to your build.gradle) Having Retrofit's logs would be a huge help.
I've attempted both. Initially, I had it set up as a gradle dependency, but I ended up pulling the source to change the logging level as per requested earlier.
OK, I'm going to attempt a quick experiment with the logging, to verify from a clean environment that everything works as intended.
I included the sdk again and logging started to work... sorry about that.
7-17 13:53:23.374 D/Retrofit﹕ ---> HTTP POST https://api.particle.io/v1/device_claims 07-17 13:53:23.374 D/Retrofit﹕ ---> END HTTP (no body) 07-17 13:53:23.375 D/Retrofit﹕ ---- ERROR https://api.particle.io/v1/device_claims 07-17 13:53:23.377 D/Retrofit﹕ java.lang.IllegalArgumentException: method POST must have a request body. at com.squareup.okhttp.Request$Builder.method(Request.java:244) at retrofit.client.OkClient.createRequest(OkClient.java:59) at retrofit.client.OkClient.execute(OkClient.java:53) at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) at java.lang.reflect.Proxy.invoke(Proxy.java:393) at $Proxy0.generateClaimCode(Unknown Source) at io.particle.android.sdk.cloud.SparkCloud.generateClaimCode(SparkCloud.java:339) at io.particle.android.sdk.devicesetup.ui.GetReadyActivity$3.callApi(GetReadyActivity.java:104) at io.particle.android.sdk.devicesetup.ui.GetReadyActivity$3.callApi(GetReadyActivity.java:101) at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:104) at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:70) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) 07-17 13:53:23.377 D/Retrofit﹕ ---- END ERROR
Much better! :) What version of OkHttp are you using? Are you specifying one on your own, or just pulling in whatever's coming from Gradle?
2.3.0 the same version that is used in spark-cloudsdk
I did a little research and it looks like this is most often caused by using OkHttp 2.4. (see https://github.com/square/retrofit/issues/854 ) I'm betting something somewhere else in your dep. chain is requesting an upgrade to OkHttp 2.4 (or more likely, is doing an evil wildcard upgrade, asking for ...okhttp:2.+
), giving us a silent upgrade.
Can you check out the output of the Gradle dependencies
task and look for a line like this:
com.squareup.okhttp:okhttp:2.3.0 -> 2.4.0
?
If this is what's going on, there's a very reasonable workaround (seen here: https://github.com/square/retrofit/issues/854#issuecomment-111522142 ) , but I'll need to push an update to the cloud SDK. It's a fairly trivial fix, but I can't publish from where I am at the moment. I could have something out in an hour-ish perhaps? (I'm not sure what the delay is on JCenter updates, but I don't think it's very long.)
In the meantime, if you're comfortable with either of these approaches, and you want the update ASAP, you could find out what's forcing the OkHttp upgrade and use an exclude
to prevent that, or you could modify the Retrofit interface definition in ApiDefs
to implement Jake's workaround in the source.
There was indeed a dependency that was using okhttp:2.4.0. Good catch! I'm attempting to connect to a photon unit now.
Awesome. \m/
Thanks again @jensck. I do appreciate the time and effort!
@alvinsee Happy to assist. Thanks for working with me to dig through the problem!
E/Async﹕ Error calling API: Unknown error communicating with server. io.particle.android.sdk.cloud.SparkCloudException GetReadyActivity﹕ Generating claim code failed
happens onReadyButtonClicked()