title: Cloud Pub/Sub Java client API example not working locally
body: <p>I'm working through the <a href="https://cloud.google.com/pubsub/docs/quickstart-client-libraries" rel="nofollow noreferrer">Google Cloud Pub/Sub publishing example</a>.</p>
  
  <p>I use the code from the example, with the exception of using my own project ID and my own topic name. </p>
  
  <p>When trying to run the example, I get the following stack trace: </p>
  
  <pre class="lang-java prettyprint-override"><code>Exception in thread "main" java.util.concurrent.ExecutionException: com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE
      at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:552)
      at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:533)
      at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:90)
      at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:62)
      at app.purephotos.zipper.Application.main(Application.java:87)
  Caused by: com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE
      at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:69)
      at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
      at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
      at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)
      at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:68)
      at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1015)
      at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)
      at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1137)
      at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:957)
      at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:748)
      at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:515)
      at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:490)
      at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
      at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
      at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
      at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:700)
      at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
      at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
      at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
      at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:399)
      at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:507)
      at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:66)
      at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:627)
      at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:515)
      at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:686)
      at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:675)
      at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
      at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE
      at io.grpc.Status.asRuntimeException(Status.java:533)
      ... 24 more
  Caused by: java.net.NoRouteToHostException: No route to host (Host unreachable)
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:589)
      at java.net.Socket.connect(Socket.java:538)
      at java.net.Socket.&lt;init&gt;(Socket.java:434)
      at java.net.Socket.&lt;init&gt;(Socket.java:244)
      at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:277)
      at io.grpc.okhttp.OkHttpClientTransport$4.run(OkHttpClientTransport.java:541)
      at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
      ... 3 more
  
  </code></pre>
  
  <p>I am using the credentials of the service account. I am certain that credentials are valid, since I've had bad attemps where I've set the path to the credentials incorrectly, and it told me right away that the file with the credentials could not be located.</p>