错误 - 11750 TwiML响应体太大

时间:2016-11-12 06:11:04

标签: ruby-on-rails twilio

您好我已经在应用程序中集成了twilio。在twilio中,每件事都适合我。但是一旦通话结束,我就会Error - 11750 TwiML response body too large。在这里我从我的结局做了什么。

def connect
 twiml1 = Twilio::TwiML::Response.new do |r|
   r.Say "You have joined the conference."
   r.Dial do |d|
    d.Conference "#{conference_title} #{call.id}",
     waitUrl: " ",
     muted: "false",
     startConferenceOnEnter: "true",
     endConferenceOnExit: "true",
     maxParticipants: 5
    end
   end
  render xml: twiml1.to_xml
end

会议结束后,我正在做一些与申请要求相关的付款。

def call_status
if params["CallStatus"] == "completed"
  request_call = RequestCall.find { |c| c.caller_sids.include?(params["CallSid"])}
  if request_call.present?
    #save call logs
    call_log = CallLog.new(called: params[:Called], tostate: params[:CallerCountry], callercountry: params[:CallerCountry], callerzip: params[:CallerZip],
      direction: params[:Direction], timestamp: params[:Timestamp], callbacksource: params[:CallbackSource], callerstate: params[:CallerState],
      tozip: params[:ToZip], sequencenumber: params[:SequenceNumber], callsid: params[:CallSid], to: params[:To], calledzip: params[:CalledZip],
      calledcity: params[:CalledCity], tocountry: params[:ToCountry], apiversion: params[:ApiVersion], callstatus: params[:CallStatus], duration: params[:Duration],
      from: params[:From], callduration: params[:CallDuration], accountsid: params[:AccountSid], calledcountry: params[:CalledCountry], callercity: params[:CallerCity],
      caller: params[:Caller], fromcountry: params[:FromCountry], tocity: params[:ToCity], fromcity: params[:FromCity], calledstate: params[:CalledState], fromzip: params[:FromZip],
      fromstate: [:FromState], user_id: request_call.user_id, expert_id: request_call.expert_id, request_call_id: request_call.id)
      call_log.save
    #check caller length
    if request_call.call_ended == false && request_call.call_id_length == true
      # Check estimate time with total duration
      if request_call.estimated_time.to_i == call_log.duration.to_i
        release_payment = request_call.release_full_payment
      elsif request_call.estimated_time.to_i < call_log.duration.to_i
        make_payment = request_call.release_full_payment
        express_item_id = request_call.express_item_id
        extra_time = call_log.duration.to_i - request_call.estimated_time.to_i
        pending_amount = request_call.price_to_pay(extra_time)
        second_item = request_call.express_item(pending_amount)
        if second_item.code == 200
          express_payment = request_call.release_express_payment
        end
        render json: {status: true}
      elsif request_call.estimated_time.to_i > call_log.duration.to_i
        remaining_duration = request_call.estimated_time.to_i - call_log.duration.to_i
        refund_amount = request_call.price_to_pay(remaining_duration)
        refund = request_call.refund_partial_amount(refund_amount)
        release_fund = request_call.release_full_payment
        render json: {status: true}
      end
      request_call.transition_to!(:completed)
      request_call.update(twilio_allocated_number: nil, twilio_access_code: nil, call_ended: true)
    elsif request_call.call_ended == true && request_call.call_id_length == true
      render json: {status: true}
    elsif request_call.call_ended == false && request_call.call_id_length == false
      #make payment
      request_call.transition_to!(:completed)
      request_call.update(twilio_allocated_number: nil, twilio_access_code: nil, call_ended: true, single_user: true)
      render json: {status: true}
    end
  else
    render json: {status: false}
  end
else
  render json: {status: false}
end

我不知道我在这方面做错了什么。请指教我。

1 个答案:

答案 0 :(得分:0)

由于我们系统的性质,处理如此分散,计算电话的价格和持续时间需要更长的时间,所以在通话结束后,我至少会扣留30个海底电话,特别是在通话期间高音量的高峰。

支持建议对REST API使用GET请求将此信息提取到您的系统中,而不是尝试在TwiML中执行此操作。您不会遇到大小限制,并且您不会为需要处理的字段(如价格,持续时间,状态等)提取空值。