<p>It's my first time using google pubsub on production. We are using the Python client and deploying projects with docker and k8s. The code snippet is just as the sample code provided by google.</p>
<pre class="lang-py prettyprint-override"><code>    os.environ[&quot;GOOGLE_APPLICATION_CREDENTIALS&quot;] = config[&quot;GOOGLE_APPLICATION_CREDENTIALS&quot;]
    project_id = &quot;abc&quot;
    topic_id = &quot;asd&quot;
    self._publisher = pubsub_v1.PublisherClient()
    self._topic_path = self._publisher.topic_path(project_id, topic_id)
    log_info_json = json.dumps({&quot;id&quot;: 1})
    publish_future = self._publisher.publish(self._topic_path, log_info_json.encode(&quot;utf-8&quot;))
    publish_future.result(timeout=5)
</code></pre>
<p>The code works fine locally, however, the k8s cluster has network constraints and I think this is the reason why we keep getting <code>TimeoutError</code> when we try on production. I have already made <code>*.googleapis.com</code> and <code>*.google.com</code> accessible but the error still exists. I have already tried to access the pod and ensure that all the links in the <code>GOOGLE_APPLICATION_CREDENTIALS</code> json file are accessible.</p>

DYX
<p>@DYX, As you have mentioned in the comment, this issue was because of an unstable network and when using the client library it just hangs there forever.</p>
<p>This issue was resolved using <a href="https://cloud.google.com/pubsub/docs/reference/rest" rel="nofollow noreferrer">API call</a> instead of the client library.</p>
<p>If the issue persists, if you have a support plan you can create a new GCP <a href="https://cloud.google.com/support/" rel="nofollow noreferrer">support case</a>. Otherwise, you can open a new issue on the <a href="https://cloud.google.com/support/docs/issue-trackers" rel="nofollow noreferrer">issue tracker</a> describing your issue.</p>
<p>Posting the answer as community wiki for the benefit of the community that might encounter this use case in the future.</p>
<p>Feel free to edit this answer for additional information.</p>
