# Pubsub input stopped - context deadline exceeded

**URL:** <https://discuss.elastic.co/t/pubsub-input-stopped-context-deadline-exceeded/293585>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 5, 2022, 7:59pm UTC](https://discuss.elastic.co/t/pubsub-input-stopped-context-deadline-exceeded/293585 "2022-01-05T19:59:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitzang1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nitzang1/32/74807_2.png) [@nitzang1](https://discuss.elastic.co/u/nitzang1)\
**Post date:** [January 5, 2022, 7:59pm UTC](https://discuss.elastic.co/t/pubsub-input-stopped-context-deadline-exceeded/293585/1 "2022-01-05T19:59:21Z")

</div>

Hi all,

I'm facing an issue where filebeat pubsub input stop pulling events just after throwing this error:

```auto
2022-01-05T15:30:24.404Z	ERROR	[gcp.pubsub]	gcppubsub/input.go:141	context deadline exceeded	{"pubsub_project": "project-1", "pubsub_topic": "some-logs", "pubsub_subscription": {"Name":"some-logs","NumGoroutines":1,"MaxOutstandingMessages":-1,"Create":false}}

```

restarting the service works but is not a solution.

Does anyone have any experience with that?

filebeat.yml:

```auto
filebeat.inputs:
    - type: gcp-pubsub
      project_id: project-1
      topic: some-logs
      subscription:
        name: some-logs
        create: false
        num_goroutines: 1
        max_outstanding_messages: -1
      credentials_file: /etc/gcp/sa_credentials.json

```

Thanks

---

<div class="post-metadata">

**Author:** ![nitzang1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nitzang1/32/74807_2.png) [@nitzang1](https://discuss.elastic.co/u/nitzang1)\
**Post date:** [January 25, 2022, 4:25pm UTC](https://discuss.elastic.co/t/pubsub-input-stopped-context-deadline-exceeded/293585/2 "2022-01-25T16:25:00Z")

</div>

This is a known bug and was fixed on 7.17.0:

> <https://github.com/elastic/beats/issues/29352>
>
> The gcppubsub input sometimes stops due to a timed-out context. Our input code d…oes not use timed contexts AFAIK so I suspect the issue lies with the pubsub library. The library is supposed to automatically retry \`Receive\` calls as per https://pkg.go.dev/gocloud.dev/pubsub#Subscription.Receive.
> 
> So as a solution I think we can do two things:
> 
> \- ✅ Upgrade the pubsub library from v1.0.1 to the latest on the hopes that this issue has been addressed.
> \- 🚫 Add our own retry loop with backoff that will continue the subscription.Receive call. (update: library update alone appears to be a reliable fix)
> 
> For confirmed bugs, please report:
> \- Version: 7.15.2
> \- Steps to Reproduce:
> 1. Configure pubsub input.
> 2. Let it run for a few days.
> 3. Input will stop.
> 
> \`2021-11-09T14:37:40.604Z ERROR \[gcp.pubsub\] gcppubsub/input.go:141 context deadline exceeded\`
> \`2021-11-09T14:37:40.604Z INFO \[gcp.pubsub\] gcppubsub/input.go:142 Pub/Sub input worker has stopped. \`
> 
> 
> Relevant code:
> 
> https://github.com/elastic/beats/blob/545598f48058408996529af3252b1b28d6dbf53d/x-pack/filebeat/input/gcppubsub/input.go#L168-L174

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 22, 2022, 6:25pm UTC](https://discuss.elastic.co/t/pubsub-input-stopped-context-deadline-exceeded/293585/3 "2022-02-22T18:25:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
