Skip to content

Commit

Permalink
リトライの条件にサーバからの切断を追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Dec 23, 2024
1 parent e36c3aa commit 874bc37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

## develop

- [CHANGE] サーバから切断された場合はリトライするように変更する
- Amazon Transcribe のみ対象
- @Hexa

### misc

- [CHANGE] GitHub Actions の ubuntu-latest を ubuntu-24.04 に変更する
Expand Down
5 changes: 5 additions & 0 deletions amazon_transcribe_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"io"
"strings"
"sync"

"github.com/aws/aws-sdk-go/service/transcribestreamingservice"
Expand Down Expand Up @@ -187,6 +188,10 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, opusCh chan opusCh
*transcribestreamingservice.InternalFailureException:
err = errors.Join(err, ErrServerDisconnected)
default:
// サーバから切断された場合は再接続を試みる
if strings.Contains(err.Error(), "http2: server sent GOAWAY and closed the connection;") {
err = errors.Join(err, ErrServerDisconnected)
}
}

w.CloseWithError(err)
Expand Down

0 comments on commit 874bc37

Please sign in to comment.