Skip to content

speech: API is leaking connections #711

@snktagarwal

Description

@snktagarwal

I am using Speech API v0.10.0 and running into open connections in my client. I am using the following stub code:
main() {
....
477 ctx := context.Background()
478 // Create a google speech API client
479 client, err = speech.NewClient(ctx, option.WithServiceAccountFile(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")))
480 if err != nil {
481 log.Println("Err: Cannot create speech client")
482 return
483 }
484 defer client.Close()
}

116 ctx := context.Background()
117 speechStream, err := client.StreamingRecognize(ctx)

I call the following when I finish reading audio like this:

264 err := speechStream.CloseSend()
265 if err != nil {
266 log.Printf("CloseSend failed due to %+v", err)
267 }

I am consistently seeing that CloseSend succeeds (err is nil) but I keep having a increase in number of connections. I tried to GRPC debug this before coming here: grpc/grpc-go#1402

Reading from above issue it looks like creating a new RPC should not always mean creating a new connection. Although, the way I am leaking it looks like each streaming RPC is leaking a dangling client connection. Other notes:

  1. main() is called once and creates a RPC server
  2. I stream audio every 55s (because of 1min limit) and that's when I create a new speechStream. I close the speechStream after the 55s deadline.

Is this the right way to go around the 55 sec deadline when doing transcription? Is there any behavior of closing streams down that I am not handling properly?

Metadata

Metadata

Assignees

Labels

api: speechIssues related to the Speech-to-Text API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions