C# TMDbClient HttpRequestException: An error occurred while sending the request - c#

I'm using the TMDbLib https://www.nuget.org/packages/TMDbLib/ 1.9.2 (upgraded due to error bellow) to grab info about TV shows. Until a day or so ago, this has been working.
Some aspects are still working. I've checked my API Key, and that is valid.
I'm getting the following errors
// Access to The Movie DB API
TMDbClient client = new TMDbClient(<API KEY>);
Error: but no exception
'client.Config' threw an exception of type 'System.InvalidOperationException'
Then
var NewEpisode = client.GetTvEpisodeAsync(TMDBid, SeasonNumber, Epnum).Result;
Error: with exceptions
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
HttpRequestException: An error occurred while sending the request.
Inner Exception 2:
WebException: The underlying connection was closed: An unexpected error occurred on a receive.
Inner Exception 3:
IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception 4:
SocketException: An existing connection was forcibly closed by the remote host
Are these related, and how might I fix this? BTW I have Fast internet.

I think I've fixed this
Putting here in case someone else has similar issues
themoviedb.org uses TLS 1.3
Turns out I was using an older version of .NET framework that doesn't support TLS 1.3
Ref:
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls
and
The request was aborted could not create SSL/TLS secure channel - HttpWebRequest
Uninstalled TMDBLib and System.Net.Http
Updated to newer .Net Framework
Reinstalled TMDBLib, System.Net.Http is a dependency so gets installed by default

Related

Query does not work with Azure Database for MySQL, but works in on-prem MySQL instance

I recently replaced an on-prem MySQL server with Azure Database for MySQL. I have a .NET 6 C# application and it works when connected to the on-prem, but has a problem with the Azure DB. Both databases are version 5.7.32.
When the app is connected to the Azure DB, all of the SQL queries work except for one. That one SQL query throws the error shown below. The query is pretty ugly and has a lot of joins and nested selects, but it works with the on-prem. I can get the query to work if I remove some of the joins.
Is there anything else I can do to troubleshoot this or get a better understanding of what the problem is? Right now, it looks like I have to refactor the query, but I really would like more detail on what the problem was.
MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Fatal error encountered during command execution.
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at XXXX.cs:line XXXX
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
MySqlException: Fatal error encountered attempting to read the resultset.
Inner Exception 2:
MySqlException: Reading from the stream has failed.
Inner Exception 3:
IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
Inner Exception 4:
SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

'System.AggregateException' when attempting to connect to my Common Data Service web api

Here is my code:
string url = "https://myOrg.api.crm.dynamics.com";
string apiVersion = "9.1";
string webApiUrl = $"{url}/api/data/v{apiVersion}/";
var authParameters = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(webApiUrl)).Result;
My last line of code is failing with:
The ouput is:
MyAPITest.vshost.exe Error: 0 : 11/05/2019 19:20:17: - AuthenticationParameters: System.ArgumentException: Unauthorized Http Status Code (401) was expected in the response
Parameter name: response
Exception thrown: 'System.AggregateException' in mscorlib.dll
The program '[5556] MyAPITest.vshost.exe' has exited with code -1 (0xffffffff).
For reference, I am attempting to use the Quick Start Guide to connect to the Common Data Service.
EDIT:
In looking at the details I am seeing:
Error
The underlying connection was closed: An unexpected error occured on a send.
More detail beneath that error:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
AuthenticationParameters: System.ArgumentException: Unauthorized Http Status Code (401) was expected in the response
The error is typically because it's lacking valid authentication credentials and the request has not been applied for the target resource.
Also if you don't know, the AuthenticationParameters.CreateFromResourceUrlAsync API is obsolete, read more there.
With this in mind, I would look into using AuthenticationParameters.CreateFromUrlAsync(Uri) Method in which should be used. It sends a GET request to the url provided with no Authenticate header. If a 401 Unauthorized is received, this helper will parse the WWW-Authenticate header to retrieve the authority and resource.
Here was the problem, found in the guide:
I am running VS 2015. Once I unchecked this, it worked perfectly.

ErrorMessage:Exchange error:The client and server cannot communicate, because they do not possess a common algorithm

I have .NET program that takes attachments from a particular mailbox id and processes the attachment file.
The problem is we have enables TLS 1.2 and disabled all old versions on windows server. Since then we are facing the following error while trying to communicate with exchange server through my .NET program.
ErrorMessage:Exchange error: The request failed. The underlying connection was closed: An unexpected error occurred on a receive.
InnerExceptionSystem.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm
below are files I have in my program:
Microsoft.Exchange.WebServices.Auth.dll
Microsoft.Exchange.WebServices.Auth.pdb
Microsoft.Exchange.WebServices.Auth.xml
Microsoft.Exchange.WebServices.dll
Microsoft.Exchange.WebServices.pdb
Microsoft.Exchange.WebServices.xml
Please let me know how I can change my code to resolve this issue.

Xamarin-PCL iOS SignalR via Https Error

I've got a problem when using SignalR on Xamarin-PCL project. The error occurred when connection.start() (The hub url is https) method, But it's worked perfectly on Android.
This is the error message
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. --->
Change the SSL/TLS implementation to "Mono (TLS v1.0)"

Intermittent System.ServiceModel.CommunicationException

I have a console app that calls a WCF service to authorize scheduled credit card payments for a given store ID. Last night it called this service over 100 times and one of those calls, it got this error:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to [service url] This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
What brought this to our attention was that this store had it's first 100 transactions authorized but 43 were left not authorized (not attempted). The service method simply grabs all 143 and does a foreach loop on them, authorizing them 1 at a time. The method returns a boolean result wrapped in a custom object that can also return error info if necessary, but that object should be small and does not change size in respect to the amount of transactions processed. I mention that because I read one case where this exception occurred in responses over a certain size. But it my case, it seems that something happened before it even tried to return. The service stopped processing in the middle of looping at which point the client received this exception. Any ideas?

Categories

Resources