question

FrancescoGiorgio-1212 avatar image
1 Vote"
FrancescoGiorgio-1212 asked SivaPrasath-5781 commented

error: The underlying connection was closed: An unexpected error occurred on a send

I am experiencing the following error, when doing translations:
The underlying connection was closed: An unexpected error occurred on a send

This has happened suddenly without any change by my side of the script configuration.

I also can read in Resource Integrity: Not possible to determine the status of integrity of the resource Cognitive Services at the moment.



I am wondering if this relates to a known Microsoft Azure issue or if I should do any fix on my side.

Thank you

dotnet-csharpdotnet-runtimeazure-cognitive-servicesazure-translatorazure-cognitive-search
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

We're getting the same issue on calls to an O365 Sharepoint site.

0 Votes 0 ·

Hi, thanks for reaching out. Are you using a global, regional, or multi-service resource to authenticate? If using a regional resource, can you please share the region?

0 Votes 0 ·

I I have tried adding the below ones but still I'm getting the same error. I have tried adding at the beginning / Just the line before ExecuteQuery() but no luck. I'm invoking the SharePoint Online using the ClientContext. I'm using .NET framework 4.7.2. Let me know if I'm missing something?

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;

0 Votes 0 ·
Stephen-5306 avatar image
1 Vote"
Stephen-5306 answered FrancescoGiorgio-1212 commented

After MS support pointed us in the direction of TLS, adding the following line fixed the error for us:

 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

Still don't understand why after years of working fine today was the day it needed to be changed.

Edit: While the above definitely fixed the error, the line we ended up using was:
System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;

· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The resource to authenticate is Global.

The error happens when calling the following API:
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=it&to=DE&to=EN&to=FR&to=ES&to=NL

and precisely when calling this method: System.Net.HttpWebRequest.GetResponse()


“Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host”

Stack Trace: in System.Net.HttpWebRequest.GetResponse()

Inner exception:
in System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
in System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)

Error code: 10054
SocketErrorCode: ConnectionReset {10054} System.Net.Sockets.SocketError

1 Vote 1 ·

Thank you Stephen, I had to adapt this fix to .net framework, but it worked also!
Thank you very much for sharing.

I agree I can't believe they suddenly have deprecated previous TLS versions, without any warning...

0 Votes 0 ·

Same problem. Same solution. Thanks!

0 Votes 0 ·

Same problem. Same solution. Thank you!!

0 Votes 0 ·

hey stephen.
i think i am missing a small piece of the puzzle :) so if this is a stupid question bear with me
where did you add this line.
in the application or in the api call.

0 Votes 0 ·

Since this was a production hotfix for us, we added the line right before creating the request object that was failing.

If this was something we had time to fix, we would've applied it at application/service start up instead.

0 Votes 0 ·
AnindyaChakrabortyIN-9804 avatar image
0 Votes"
AnindyaChakrabortyIN-9804 answered SivaPrasath-5781 commented

Facing this issue to connect from PBI ? anyone can help me

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Anindya,

After lots of back and forth, I was not able to fix it. Finally what fixed for us is, When we deployed to Windows 2016 R2, it started working. If in case, you are deploying on old windows version try it in latest windows server.

0 Votes 0 ·