I have everything working locally, but when I test Twilio's service on an Amazon EC2 Debian 6.0.6 server running Mono 2.10.9, I find that sending SMS messages no longer works. I believe the problem lies somewhere in the server configuration, as I am using the latest Twilio (3.5.6), RestSharp (104.1) and JSON.NET (4.5.11) libraries, and I can guarantee that the variables used in the following method call are not empty at runtime.
var client = new Twilio.TwilioRestClient("{my account number}", "{my account token}");
var smsMessage = client.SendSmsMessage("{my account phone number}", "{my mobile phone number}", "Hello World!");
Using ntop, I have seen that there are bytes being sent/received to/form this reqeuest, but the smsMessage result is still null. The SendSMSMessage function utilizes the RestSharp library, particularly the RestClient's Execute function, which invokes a Deserialize method and returns an IRestResponse in which the Data field is null in this case.
I have seen some indications online that the problem may lie in the deserialization process, but, as I've ensured I am using the latest version of JSON.NET, I am not sure what other steps to take here.
Do you have any suggestions on resolving the problem and do you suspect it is a code or server issue? Also do you have any advice, using Debian, how I might further debug this interaction, perhaps even to get the full byte response externally from the application?
In debugging the RestSharp library, I discovered that the exception had to do with SSL and Mono's trusted certificates. The exception message I received is as follows:
Error getting response stream (Write: The authentication or decryption has failed.): SendFailure
Following the instructions in the link below helped me to resolve the issue, particularly by executing the following and restarting mono.
certmgr -ssl https://api.twilio.com
http://www.mono-project.com/FAQ:_Security
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With