Skip to content

Commit

Permalink
Merge pull request #348 from getAlby/fix/rabbit-connection
Browse files Browse the repository at this point in the history
prevent EOF loop
  • Loading branch information
kiwiidb authored Apr 13, 2023
2 parents c7f2d85 + e167940 commit 099f63a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func main() {
err = svc.RabbitMQClient.SubscribeToLndInvoices(backGroundCtx, svc.ProcessInvoiceUpdate)
if err != nil && err != context.Canceled {
// in case of an error in this routine, we want to restart LNDhub
sentry.CaptureException(err)
svc.Logger.Fatal(err)
}

Expand Down
5 changes: 4 additions & 1 deletion rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ func (client *DefaultClient) SubscribeToLndInvoices(ctx context.Context, handler
select {
case <-ctx.Done():
return context.Canceled
case delivery := <-deliveryChan:
case delivery, ok := <-deliveryChan:
if !ok {
return fmt.Errorf("Disconnected from RabbitMQ")
}
var invoice lnrpc.Invoice

err := json.Unmarshal(delivery.Body, &invoice)
Expand Down

0 comments on commit 099f63a

Please sign in to comment.