Twilio Bulk Messages with ShortCode throughput with C# -
i trying track down performance issue not allowing me send more 3 or message twilio c# api. in short, have windows service responds bulk 'join' messages. see following code:
int = 0; datetime d = datetime.now; timespan ts = new timespan(0,0,1); foreach (customertextmessage t in o) { i++; threadinput ti = new threadinput { messageids = i, body = t.body, threadcreated = datetime.now, fromnumber = t.fromnumber }; threadpool.queueuserworkitem(new waitcallback(processresponselist), (object)ti); }
the processresponselist method quick on customer, responds using method:
public static void sendresponse(string number, string body) { string accountsid = configurationmanager.appsettings["accountsid"]; string authtoken = configurationmanager.appsettings["accounttoken"]; var twilio = new twiliorestclient(accountsid, authtoken); string fromnumber = ""; if (configurationmanager.appsettings["stageexecution"] == "true") { businesslayer.slosbl.logger logger = new businesslayer.slosbl.logger("discovertextmessagingservice", "discovertextmessagingservice"); authtoken = configurationmanager.appsettings["stageapplicationtoken"]; var longcodes = twilio.listincomingphonenumbers(null, "stagephonenumber", null, null); fromnumber = longcodes.incomingphonenumbers[1].phonenumber; logger.notify("sending text message to: " + number + " twilio number: " + fromnumber + ". body of message reads: " + body); } else { var shortcodes = twilio.listshortcodes(null, null); fromnumber = "+" + shortcodes.shortcodes[0].shortcode; } //var message = twilio.sendmessage(fromnumber, number, body, new string[0], null, authtoken ); datetime d = datetime.now; twilio.sendmessage(fromnumber, number, body, new string[0], null, authtoken, null, m => { messageasynccallback(m, d); }); }
what seeing is able send these message 3 every second. looking increase closer 30 every second short code possible not able them twilio queue fast enough. question, there obvious should doing? should reusing twiliorestclient variable message? there limit number of connections someplace missing? in advance.
Comments
Post a Comment