If you can't read please download the document
Upload
vag-elis
View
59
Download
1
Embed Size (px)
Citation preview
SMS MESSAGINGWITH RUBYVaggelis Typaldos - @vtypal
ASYNCHRONOUS
OVERVIEW
SMSShort Message Service
What is? Why use it?
SMS PROSSms is easy Sms is available to everybody Sms is a high revenue communication channel
SMS CONSSms is short (plain text of 160 chars max.) Send sms is not cost free Sms black hours Legal conditions
SMSCShort Message Service Center
Send and receive SMS & DLRs Check msisdn to HLR database Assign a short code (4-digit) number to our bind Set throughput (sms rate) SMSC talks to (ESME) clients via SMPP protocol
SMPP PROTOCOL (V_3.4)Short Message Peer to Peer Protocol
Peer to peer over tcp protocol between ESME (external short messaging entities) clients and SMSC for sending/receiving SMS messages. Each tcp packet is called PDU (Protocol Data Unit) bind_sm/bind_sm_resp enquire_link/enquire_link_resp submit_sm/submit_sm_resp deliver_sm/deliver_sm_resp
TYPICAL SMPP REQUEST - RESPONSE
KANNEL SMS GATEWAYPROSOpen source Fast and Light Single configuration file Local store for sms Split long text messages in more parts Rich API
KANNEL.CONF (BEARERBOX)gop=cr ru oe amnpr =100 di-ot 30 sso-ot=101 mbxpr 30 amnpswr =br di-asod a soelcto ="apgtwy150lg/anlsoe tr-oain /p/aea-../oskne.tr" #SS SP MC MP gop=ss ru mc ss =sp mc mp ss-d="mc mci ss" hs =1.01.0 ot 01.01 pr =90 ot 00 sse-ye=EM ytmtp SE ss-srae="22 mcuenm 22" ss-asod="22as mcpswr 22ps" tasevrmd =tu rncie-oe re suc-drtn=0 oread-o suc-drni=1 oread-p itraevrin=3 nefc-eso 4 ds-drtn=1 etad-o ds-drni=5 etad-p mxpnigsbis=5 a-edn-umt 0 truhu =5 hogpt 0 #odrtu n-l=re
KANNEL.CONF (SMSBOX)gop=sso ru mbx baebxhs =lclot erro-ot oahs snsspr =106 edm-ot 30 m-eoe=tu orcd re ht-eus-er =3 tprqetrty #SN-M UES EDSS SR gop=snssue ru edm-sr uenm =tse srae etr pswr =foa asod obr #SRIE EVCS gop=sssrie ru m-evc #a-esgs=1 mxmsae 0 gtul= ht:/psre:00mapm?rm%&o%&et%&cd% e-r tp/apevr80/yp/ofo=pt=Ptx=ako=c &ca=Css=itm=t khr%&mc%&ie% acpe-mc=ss cetdss mc
RECEIVING MOMobile Originated
Retrieve the parameters defined in get-url(or post-url) of kannel.confht:/psre:00mapm? tp/apevr80/yp/o fo=pt=Ptx=ako=ckhr%&mc%&ie% rm%&o%&et%&cd%&ca=Css=itm=t
casMAp ls yp dfm e o i rqetgt f eus.e? @aasrqetprm prm=eus.aas rtr % eun | ====== M rcie a # @aas'ie]}====== ====== O eevd t { prm[tm' ====== Fo: # @aas'rm]} rm { prm[fo' T; o # @aas'o]} { prm[t' Ss:# @aas'mc]} mc { prm[ss' Msae # @aas'et]} esg: { prm[tx' ================= ================= | ed n ed n ed n
SENDING MTMobile Terminated
GET request to the sendsms port of smsbox defined in kannel.confht:/mgtwy106cibnsnsst=0091357fo=24uenm= tp/ssaea:30/g-i/edm?o3364246&rm13&sraet etrpswr=obr se&asodfoa &etAhn Rb Meu (tesr)i agopo (o js)geswolv R tx=tes uy etp Ahn.b s ru f nt ut ek h oe uy(mn ohrtig) b aog te hns adme rglryi Ahn i odrt dsusadpeeto altig Rb n et eual n tes n re o ics n rsn n l hns u y..adhv besoz, .. n ae er,uo tior a wl a ohrachlc(n smtmsnnachlc bvrgs spuo s el s te looi ad oeie o-looi) eeae. &mcss&oig0castUF8atds0 ss=mccdn=&hre=T-&l-c=
Try it using your browser (will work) In your ruby code you must url encode the text
URI.ENCODE_WWW_FORM_COMPONENT(TEXT)Ahn+uyMeu+2Ahn.b2+sagopo+2ntjs%9ges tesRb+etp%8tesr%9i++ru+f%8o+ut2+ek+ wolv+uy%8mn+te+hns2%An+ h+oeRb+2aogohrtig%90ad me+eual+nAhn+nodrt+ics+ etrglryi+tesi+re+odsus adpeeto+l+hnsRb..adhv+ n+rsn+naltig+uy.+n+ae bes2oz%C0tior+swl+sohr er%Cuo2%Aspuoa+ela+te+ achlc%8n+oeie+o-looi%9bvrgs looi+2adsmtmsnnachlc2+eeae.
MT examplerqie'r' eur ui rqie'e/tp eur ntht' ui=UIpre'tp/ssaea:30/g-i/edm', r R.as(ht:/mgtwy106cibnsnss) prm ={:o= "091357,:rm= "24, aas t > 364246" fo > 13" :srae>tse" :asod>foa" uenm="etr, pswr="obr, :et>Ahn Rb Meu (tesr)i agopo tx="tes uy etp Ahn.b s ru f (o js)geswolv Rb (mn ohrtig)ad nt ut ek h oe uy aog te hns n me rglryi Ahn i odrt dsusadpeet et eual n tes n re o ics n rsn o altig Rb.. adhv besoz, n l hns uy.. n ae er,uo tior a wl a ohrachlc(n smtms spuo s el s te looi ad oeie nnachlc bvrgs" ec} o-looi) eeae., t #Adprm t UI d aas o R uiqey=UIecd_w_om prm ) r.ur R.noewwfr( aas pt Nt:TPgtui us e:HT.e(r)
REQUESTING DELIVERY REPORTSdlr-url (url-encoded) dlr-maskht:/mgtwy106cibnsnsst=0091357fo=24uenm= tp/ssaea:30/g-i/edm?o3364246&rm13&sraet etrpswr=obr se&asodfoa &etAhn Rb Meu (tesr)i agopo (o js)geswolv R tx=tes uy etp Ahn.b s ru f nt ut ek h oe uy(mn ohrtig) b aog te hns adme rglryi Ahn i odrt dsusadpeeto altig Rb n et eual n tes n re o ics n rsn n l hns u y..adhv besoz, .. n ae er,uo tior a wl a ohrachlc(n smtmsnnachlc bvrgs spuo s el s te looi ad oeie o-looi) eeae. &mcss&oig0castUF8atds0 ss=mccdn=&hre=T-&l-c=& drulht:/mgtwy80/yp/l?sI=2821tp=ddrms= l-r=tp/ssaea:00mapdrmgd2163&ye%&l-ak3
ht:/mgtwy106cibnsnsst=0091357fo=24uenm= tp/ssaea:30/g-i/edm?o3364246&rm13&sraet etrpswr=obr se&asodfoa &etAhn+uyMeu+2Ahn.b2+sagopo+2ntjs%9ges tx=tesRb+etp%8tesr%9i++ru+f%8o+ut2+ek+ wolv+uy%8mn+te+hns2%An+ h+oeRb+2aogohrtig%90ad me+eual+nAhn+nodrt+ics+ etrglryi+tesi+re+odsus adpeeto+l+hnsRb..adhv+ n+rsn+naltig+uy.+n+ae bes2oz%C0tior+swl+sohr er%Cuo2%Aspuoa+ela+te+ achlc%8n+oeie+o-looi%9bvrgs looi+2adsmtmsnnachlc2+eeae. &mcss&oig0castUF8atds0 ss=mccdn=&hre=T-&l-c=& drulht%A2%Fmgtwy380%Fyp%Fl%FsI%D28212tp l-r=tp3%F2ssaea%A002map2dr3mgd32163%6ye %D2&l-ak3 3%5drms=
MT with DLR examplerqie'r' eur ui rqie'e/tp eur ntht' ui=UIpre'tp/ssaea:30/g-i/edm', r R.as(ht:/mgtwy106cibnsnss) prm ={:o= "091357,:rm= "24, aas t > 364246" fo > 13" :srae>tse" :asod>foa" uenm="etr, pswr="obr, :et>Ahn Rb Meu (tesr)i agopo tx="tes uy etp Ahn.b s ru f (o js)geswolv Rb (mn ohrtig)ad nt ut ek h oe uy aog te hns n me rglryi Ahn i odrt dsusadpeet et eual n tes n re o ics n rsn o altig Rb.. adhv besoz, n l hns uy.. n ae er,uo tior a wl a ohrachlc(n smtms spuo s el s te looi ad oeie nnachlc bvrgs" ec. o-looi) eeae., t., :l-r = "tp/ssaea:00mapdrmgd2163&ye%" drul > ht:/mgtwy80/yp/l?sI=2821tp=d, :l-ak=3} drms > #Adprm t UI d aas o R uiqey=UIecd_w_om prm ) r.ur R.noewwfr( aas pt Nt:TPgtui us e:HT.e(r)
RECEIVING DLRcasMAp ls yp .. . dfdr e l i rqetgt f eus.e? @aasrqetprm prm=eus.aas rtr % eun | ====== DRrcie ====== ====== L eevd ====== MsaeI: # @aas'sI' } esg d: { prm[mgd] Dlvr tp: eiey ye # @aas'ye]} { prm[tp' ================= ================= | ed n ed n ed n
MESSAGE BROKERprovides clients with connectivity, and message storage/delivery functions Queue: Destination that contains messages sent from a producer that await delivery to one consumer Destination: queues or topics
CLIENT TYPES
Producers (create messages and send or publish them to the broker for delivery to a specified destination) Consumers (retrieve messages from a destination)
MESSAGE BROKER PROSClustering Failover Persistence
STOMPStreaming Text Oriented Messaging Protocol (STOMP)
In activemq.xml configuration file replace the default wire protocol used by native Java Message Broker clients with stomp transport connector that supports clients written in languages such as Ruby, Perl, Python, and PHP.tasotonco nm=oewr"ui"c:/oahs rnprCnetr ae"pnie r=tp/lclo t666 :11" tasotonco nm=sop ui"tm:/oahs rnprCnetr ae"tm" r=sop/lclot :11" 666
PRODUCER-PUBLISHER#raeteqee(fde nteit Cet h uu i os o xs) #adpplt teqeewt msae n ouae h uu ih esgs rqie'tm' eur sop cin =Sop:letoe "tm:/oahs:11" let tm:Cin.pn sop/lclot666 1ut(0 d .po5) o cin.uls(/uu/b" Tm.o.tfie"H%-s) {:esset= letpbih"qeerq, ienwsrtm(%-M%", pritn >tu } re ) #cin.uls(/oi/ht,"el Rbse!,{:esset= tu } letpbih"tpcca" Hlo uyts" pritn > re ) sep2 le ed n cin.ls letcoe
CONSUMER-SUBSCRIBERrqie'tm' eur sop cin =Sop:letoe "tm:/oahs:11" let tm:Cin.pn sop/lclot666 cin.usrb "qeerq d |esg| letsbcie /uu/b" o msae pt "eevd #msaebd}o #msaehaes'etnto'} us rcie: {esg.oy n {esg.edr[dsiain]" ed n cin.on letji cin.ls letcoe
ACTIMEMQ ADMIN UI
THE ENDBY VTYPAL