title: ManagedChannel not shut down properly
body: <p>The error I put below, where a ManagedChannel was not shut down properly. I have read this <a href="https://github.com/actions-on-google/actions-on-google-java/issues/30" rel="nofollow noreferrer">issue</a>, but couldn't find a solution: . So the question here is: what do I need to shut down and how?</p>
  <p>I have basically completely copied the code from Google's <a href="https://developers.google.com/assistant/smarthome/develop/report-state#java" rel="nofollow noreferrer">docs</a>. I will put the faulty class below the error as well. I have tried finding a &quot;shutdown&quot; method on all of the variables, but there aren't any, so I'm not sure what I should do.</p>
  <pre><code>2021-01-18 19:21:59.443 ERROR 1 --- [nio-8080-exec-8] i.g.i.ManagedChannelOrphanWrapper        : *~*~*~ Channel ManagedChannelImpl{logId=157, target=homegraph.googleapis.com} was not shutdown properly!!! ~*~*~*                         │
  │     Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.                                                                                                                                             │
  │ java.lang.RuntimeException: ManagedChannel allocation site                                                                                                                                                                                 │
  │     at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.&lt;init&gt;(ManagedChannelOrphanWrapper.java:103) ~[grpc-core-1.15.1.jar!/:1.15.1]                                                                                  │
  │     at io.grpc.internal.ManagedChannelOrphanWrapper.&lt;init&gt;(ManagedChannelOrphanWrapper.java:53) ~[grpc-core-1.15.1.jar!/:1.15.1]                                                                                                           │
  │     at io.grpc.internal.ManagedChannelOrphanWrapper.&lt;init&gt;(ManagedChannelOrphanWrapper.java:44) ~[grpc-core-1.15.1.jar!/:1.15.1]                                                                                                           │
  │     at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:410) ~[grpc-core-1.15.1.jar!/:1.15.1]                                                                                               │
  │     at com.google.actions.api.smarthome.SmartHomeApp.reportState(SmartHomeApp.kt:126) ~[actions-on-google-1.8.0.jar!/:na]                                                                                                                  │
  │     at ordina.engie.googlehome.google.services.ReportStateService.reportState(ReportStateService.java:41) ~[classes!/:0.0.1-SNAPSHOT]                                                                                                      │
  │     at ordina.engie.googlehome.toon.controllers.ToonController.reportToGoogle(ToonController.java:27) ~[classes!/:0.0.1-SNAPSHOT]
  </code></pre>
  <p>The method where the error happens:</p>
  <pre class="lang-java prettyprint-override"><code>public void reportState(String requestId, String commonName, ThermostatInfo thermostatInfo) {
          Value deviceStates =
                  Value.newBuilder()
                          .setStructValue(
                                  Struct.newBuilder()
                                          .putFields(HOME_RESPONSE_KEY_ONLINE, Value.newBuilder().setBoolValue(true).build())
                                          .putFields(HOME_RESPONSE_KEY_MODE, Value.newBuilder().setStringValue(smartHomeHelperService.calculateThermostatMode(thermostatInfo)).build())
                                          .putFields(HOME_RESPONSE_KEY_SETPOINT, Value.newBuilder().setNumberValue(thermostatInfo.getCurrentSetpoint()).build())
                                          .putFields(HOME_RESPONSE_KEY_AMBIENT, Value.newBuilder().setNumberValue(thermostatInfo.getCurrentDisplayTemp()).build())
                                          .build())
                          .build();
  
          Struct requestStates = Struct.newBuilder().putFields(commonName, deviceStates).build();
  
          HomeGraphApiServiceProto.ReportStateAndNotificationResponse response =
                  engieSmartHomeAppService.reportState(
                          HomeGraphApiServiceProto.ReportStateAndNotificationRequest.newBuilder()
                                  .setRequestId(requestId)
                                  .setAgentUserId(commonName)
                                  .setPayload(
                                          HomeGraphApiServiceProto.StateAndNotificationPayload.newBuilder()
                                                  .setDevices(
                                                          HomeGraphApiServiceProto.ReportStateAndNotificationDevice.newBuilder()
                                                                  .setStates(requestStates)
                                                                  .build())
                                                  .build())
                                  .build());
      }
  </code></pre>