Reputation: 361
I have a lib with service witch calls Twilio api to send sms message. This lib is used in ASP MWC project. And the fuction SendMessage returns null. I pasted this code in a new console app, and it worked well - sms message has been sent. I don't understand why the exact same code doesn't work in my project.
Twilio.Api 3.4.1.0
Code
string AuthToken = "___";
string AccountSid = "___";
string Sender = "___";
TwilioRestClient Client = new TwilioRestClient(AccountSid, AuthToken);
var smsMessage = Client.SendMessage(Sender, "197_______1", "Some text");
Maybe the is a problem with ssl? How to check it?
Upvotes: 0
Views: 762
Reputation: 361
In global.asax file in Application_Start method I commented out code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
And sending messages's worked. So i suggested that the issue was because of on my machine ssl protocol wasn't set up. But i think that for live server this isn't a good solution. And admins told me that on local machine they set up tls protocole. So I hope that when I write in global asax:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
On live server sending messages will work. If i found out it in a wrong way, please correct me.
Upvotes: 0
Reputation: 10366
Twilio evangelist here.
First, I'd making sure that the NuGet package you've pulled into your project is the latest version (4.0.2 I beleive). Note that the package version is different than the actual assembly version.
Second, check to see if the RestException property is null:
if (Client.RestException != null) {
//something bad happened
}
Finally, if neither of those suggestions help, break out an HTTP proxy tool like Fiddler and check to see if the library is actually making a successful HTTP request to Twilio.
Hope that helps.
Upvotes: 1