dwilkie / chibi

Chibi
chibitxt.me
1 stars 0 forks source link

Handle case when delivery receipt arrives before Reply is updated with token #161

Closed dwilkie closed 9 years ago

dwilkie commented 9 years ago

https://github.com/dwilkie/chibi-smsc/issues/24

dwilkie commented 9 years ago

Jobs are failing but not being retried. This could have something to do with they way they are enqueued from Jesque

dwilkie commented 9 years ago

The problem is stated here:

https://github.com/mperham/sidekiq/wiki/Resque-Compatibility#limitations

Add a parameter to retry the job over here: https://github.com/dwilkie/chibi-smsc/issues/24

dwilkie commented 9 years ago

Closed by https://github.com/dwilkie/chibi-smsc/issues/24

dwilkie commented 9 years ago
[2015-03-25 08:52:42,453,INFO] [DefaultSmppSession.sendRequestPdu:523] sync send PDU: (submit_sm: 0x00000071 0x00000004 0x00000000 0x000004EC) (body: (serviceType [vma] sourceAddr [0x00 0x01 [2442]] destAddr [0x01 0x01 [85510421118]] esmCls [0x00] regDlvry [0x01] dcs [0x01] message [4461726F3A204E617068612063616E207520536D73204F722063616C6C2077697468206D652062616E206F72743F6E756D6265722069206F6E2032343432])) (opts: )
[2015-03-25 08:52:46,685,INFO] [DefaultSmppSession.firePduReceived:589] received PDU: (deliver_sm: 0x00000064 0x00000005 0x00000000 0x000001A3) (body: (serviceType [vma] sourceAddr [0x01 0x01 [85510421118]] destAddr [0x00 0x01 [2442]] esmCls [0x04] regDlvry [0x00] dcs [0x08] message [])) (opts: (receipted_message_id: 0x001E 0x0014 [3634383438313238373438313835313637303400]) (message_state: 0x0427 0x0001 [02]) (tlv: 0x150C 0x000B [3134323732373335363000]) (tlv: 0x150D 0x0001 [05]))
[2015-03-25 08:52:46,685,INFO] [ClientSmppSessionHandler.firePduRequestReceived:36] request (deliver_sm: 0x00000064 0x00000005 0x00000000 0x000001A3) (body: (serviceType [vma] sourceAddr [0x01 0x01 [85510421118]] destAddr [0x00 0x01 [2442]] esmCls [0x04] regDlvry [0x00] dcs [0x08] message [])) (opts: (receipted_message_id: 0x001E 0x0014 [3634383438313238373438313835313637303400]) (message_state: 0x0427 0x0001 [02]) (tlv: 0x150C 0x000B [3134323732373335363000]) (tlv: 0x150D 0x0001 [05]))

submit_sm_resp

[2015-03-25 08:52:43,305,INFO] [DefaultSmppSession.firePduReceived:589] received PDU: (submit_sm_resp: 0x00000024 0x80000004 0x00000000 0x000004EC result: "OK") (body: (messageId [6484812874818516704])) (opts: )

Reply ID in Chibi: 26973730

 #<Reply id: 26973730, to: "85510421118", body: "Daro: Napha can u Sms Or call with me ban ort?numb...", user_id: 81938, chat_id: 6217006, created_at: "2015-03-25 08:52:28", updated_at: "2015-03-25 08:52:29", delivered_at: "2015-03-25 08:52:28", token: nil, state: "queued_for_smsc_delivery", smsc_message_status: nil, delivery_channel: "smsc", operator_name: "smart", smpp_server_id: "smart">

Either the submit_sm_resp was never received by Chibi or it might have been received after the delivery receipt and caused an invalid transition error.

In the retry scenario this is what could happen:

  1. submit_sm_resp comes in but reply is not found
  2. reply is retried
  3. deliver_sm_response is received but no token is found (so it's ignored)
  4. reply is retried successfully (so should have the status delivered_by_smsc

We need to solve the above case as well but this doesn't explain why the reply is still queued_for_smsc_delivery

dwilkie commented 9 years ago
Reply.where(:smpp_server_id => "smart").where(:state => "delivered_by_smsc").where(:delivery_channel => "smsc").where("delivered_at < ?", 1.day.ago).count
77786