Twilio REST Client stops working after adding Studio Flow?

时光怂恿深爱的人放手 提交于 2019-12-22 10:46:55

问题


I am using Twilio REST client in Visual Studio 2017. After adding a Studio Flow for a simple SMS autoresponder, I am no longer able to use the Twilio REST API to send a SMS message from my ASP.net app.

The error message is "Upgrade Required"

at Twilio.Clients.TwilioRestClient.ProcessReponse(Reponse response)
at Twilio.Rest.Api.V2010.Account.MessageResource.Create(CreateMessageOptions options, ITwilioRestClient client)
at...

I already tried upgrading the Twilio REST API helper library NuGet package to latest, version 5.28.0.

The error occurs on this basic SMS sending code that used to work.

Dim message = MessageResource.Create(body:=strBody, from:=New Twilio.Types.PhoneNumber(Credentials.TwilioFixityNewNumberFormatted), [to]:=New Twilio.Types.PhoneNumber(strFormattedNumber))
Return message.Sid

There are no error messages or notifications in my Twilio account that something is wrong or needed. Has anyone experienced something like this?


回答1:


It seems that modifying the Twilio project made it a "new" project subject to TLS 1.2 requirements that were just implemented on 3/28/19. The problem was solved by updating Windows and .NET to the latest updates, and explicitly enabling TLS 1.2 prior to accessing the Twilio REST API:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12   'Force TLS 1.2



回答2:


Twilio returns Upgrade Required when you use an old TLS version. Setting the version directly using ServicePointManager.SecurityProtocol does fix it, but it's not a good idea since it'll become outdated when a new TLS version is released. Instead, see Transport Layer Security (TLS) best practices with the .NET Framework for some reasons it may be selecting an older version.

In my case it was due to this line in Web.config:

<httpRuntime targetFramework="4.5" />

Setting it to the actual .NET Framework version I'm using fixed the Twilio error.



来源:https://stackoverflow.com/questions/55428324/twilio-rest-client-stops-working-after-adding-studio-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!