PnPCore store received token

62 Views Asked by At

I have a C# console application which fetches files from a Teams location. All works perfect on my laptop but when i place it on a server it works sometimes but not consistently. I receive the following error regularly.

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> 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 (10054): An existing connection was forcibly closed by the remote host.

It looks like the existing request stays open or something and it is not picked up again. I want to store the received token in order to pickup this request again instead of creating a new one each time by reusing the token.

The application uses the UsernamePassword option from PnP as below.

services.AddPnPCoreAuthentication(options =>
    {
        options.Credentials.Configurations.Add("usernamepassword",
           new PnPCoreAuthenticationCredentialConfigurationOptions
          {
              UsernamePassword = new PnPCoreAuthenticationUsernamePasswordOptions
              {
                  Username = config["Pnp:Username"],
                  Password = config["Pnp:Password"]
              },
          });
    });

What could i try to fix this issue. All help is appreciated.

I've already tried changing the routes and assigned SSL certificates to the server.

0

There are 0 best solutions below