CyCoreSystems / ari

Golang Asterisk REST Interface (ARI) library
Apache License 2.0
180 stars 74 forks source link

MatchLenOrTerminator Not waiting for all the DTMF #141

Open avraham1 opened 1 year ago

avraham1 commented 1 year ago

I want to receive a list of digits from the client, but the Play method returns immediately when the client clicks on the first digit.

This is my code:

func chooseLesson(ctx context.Context, h *ari.ChannelHandle, user *User) { res, _ := play.Play(ctx, h, play.URI(msgPath(msg)), play.MatchLenOrTerminator(10, "#")).Result() lessonId := res.DTMF // <<< Only first digit here }

where is my mistake?

Ulexus commented 1 year ago

I don't see a problem in your code... Is the caller perhaps expiring the inter-digit timer (default: 3s)? Are you, perhaps, encountering an error and not seeing it?

avraham1 commented 1 year ago

Thanks for your response.

It happens instantly, not because of the timer.

As you can see in the picture, err is nil, and status is Cancelled

What it means? Why is it cancelled?

image

Ulexus commented 1 year ago

There aren't really that many things it could be: https://github.com/CyCoreSystems/ari/blob/master/ext/play/session.go#L186-L219

Context cancellation, overall timeout, or inter-digit timeout. Since you're not getting an Invalid result, it's not that.