Keri
Keri

Reputation: 356

Inbound call sending unexepected hangup signal

I am trying to make 5 sets of 40 - 50 second recordings of an inbound caller.

I have the following TwiML which is set in response to inbound calls:

<Response>
    <Say>Recording $n</Say>
    <Record action="/twilio/answer/$n" finishOnKey="123456789#*" maxLength="50" playBeep="true" timeout="5" trim="trim-silence" />
</Response>

Where $n is a number 1 - 5.

Upon timeout or button press a post message will be sent to the following view in flask:

@app.route('/twilio/answer/<int:question_id>', methods=['POST'])
def answer(question_id):
    """Receives the question and ensures it is the correct length."""
    length = int(request.values.get("RecordingDuration", 0))
    if length >= MIN_LENGTH:
        url = request.values.get("RecordingUrl", None)
        save_url(url)
        response = redirect_to_question(question_id + 1)
        return str(response)
    else:
        # Replay question
        response = twiml.Response()
        message = """The recording must be at least %s seconds long.""" % MIN_LENGTH
        return redirect_to_question(question_id, say=message)

Half the time the call works as expected. The other half, the caller appears to send a "hangup".

POST/twilio/answer/

Request
URL
https://example.com/twilio/answer/1

Parameters
CALLED  +441234567890
DIGITS  hangup

I am definitely not hanging up.

The hangup up signal is always sent when the recording duration is 31 seconds. If the first recording/view is a success, all the other recordings/views will be as well.

I have experienced this with my my phone (Android) as well as with Skype.

I am using flask running with gunicorn:

gunicorn voice:app  -b 127.0.0.1:8000  --timeout 120  --graceful-timeout     120  --workers 3 --worker-class gevent  --log-file - --log-level debug

I am using nginx as a reverse proxy:

server {
    listen 80;
    listen 443 ssl;
    server_name example.com;

ssl_certificate somewhere/fullchain.pem;
ssl_certificate_key somewhere/privkey.pem;
ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers         HIGH:!aNULL:!MD5;

access_log  /var/log/nginx/access.log;
error_log  /var/log/nginx/error.log;

location / {
    proxy_pass         http://127.0.0.1:8000;
    proxy_redirect     http://127.0.0.1:8000 https://example.com;

    proxy_set_header   Host                 $host;
    proxy_set_header   X-Real-IP            $remote_addr;
    proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto    $scheme;
    proxy_read_timeout 120s;
}
}

It seems to me that this is a problem on Twilio's end.

Is there:

  1. Any way to fix this?
  2. A way to ignore the hangup signal and continue?

Upvotes: 1

Views: 76

Answers (1)

Keri
Keri

Reputation: 356

It turns out that the phone number is provided by a carrier that hangs up if there is no audio within 30 seconds.

Issue is fixed by using a different provider. Waiting for Twilio support to tell me how to find a number without this feature.

Upvotes: 1

Related Questions