Sub SendReplyNexmo(reply As String)
Dim w As New Net.WebClient
Dim values As New Specialized.NameValueCollection
values.Add("to", sender)
values.Add("text", reply)
values.Add("from", sentto)
values.Add("api_key", nexAPIKey)
values.Add("api_secret", nexAPISecret)
Try
w.UploadValues(New Uri("https://rest.nexmo.com/sms/json"), "POST", values)
w.Dispose()
Catch ex As Exception
Dim logFile As IO.StreamWriter
If IsNothing(HttpContext.Current) Then
logFile = New IO.StreamWriter("C:\logs\SMSerror.log", True)
Else
logFile = New IO.StreamWriter(HttpContext.Current.Server.MapPath("/logs/SMSerror.log"), True)
End If
logFile.WriteLine(ex.Message)
logFile.Dispose()
End Try
End Sub
This is the code that I am using to connect to the Nexmo API. Then, out of nowhere, my apps using this broke, and I am now getting the error.
The underlying connection was closed: An unexpected error occurred on a send.
I've tried setting a custom User Agent string, no change. I've tried searching docs.
ASP.NET 4.6.1 IIS 7.5 on Windows Server 2008 R2. Desktop versions run on windows 7
This is due to Nexmo disabling legacy TLS protocols. It now supports v1.2. You can find out more about it here. You could make a http request to the following url from your application to verify the TLS version, it should return a 200Ok if it supports 1.2 and 400 if not. In case it doesn't, this should solve the problem :
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12