Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout issue? (how to configure web service client). #2507

Closed
lerudiconsulting opened this issue Jan 19, 2018 · 11 comments
Closed

Timeout issue? (how to configure web service client). #2507

lerudiconsulting opened this issue Jan 19, 2018 · 11 comments
Assignees
Labels
tooling An issues related to any tool shipped from this repo.
Milestone

Comments

@lerudiconsulting
Copy link

Hi,

I am consuming a slow connected service and thus simply need to increase the timeout. In previous versions of .NET I could simply adjust timeout settings in the bindings in web.config, however, in ASP.NET Core 2 I cannot find the way to do this. Can you perhaps elaborate on how to do this as all I have found so far are unclosed issues related to this type of question?

Thanks in advance for your help!

/Peter

@zhenlan
Copy link
Member

zhenlan commented Jan 19, 2018

@lerudiconsulting thanks for raising the issue.

@mlacouture can you see what we need to change in the connected service generated code to make the configuration (programmatically) easier/possible.

@zhenlan zhenlan added the tooling An issues related to any tool shipped from this repo. label Jan 19, 2018
@zhenlan zhenlan added this to the S130 milestone Jan 19, 2018
@lerudiconsulting
Copy link
Author

Hi @zhenlan!

Thanks for taking action on this! Much appreciated! Look forward to the implementation! Any projection on when this is due?

Cheers!

/Peter

@lerudiconsulting
Copy link
Author

Hi again @zhenlan,

Am I to understand that there is a programmatic way of altering these values, only not a simplified way? If there is a codified way (even if it is not very simple) of doing this while I hold for the fix, I would appreciate it if someone shared this info with me.

Thanks again in advance!

/Peter

@mlacouture
Copy link
Member

Hi @lerudiconsulting

As you may know, .NET Core does not support configuration files so binding configuration needs to be done in code.

The generated proxy code provides a configuration partial method for this purpose, for example: assuming your client class is named ServiceClient and its namespace ServiceReference, you can implement the configuration method as follows:

namespace ServiceReference {
   public partial class ServiceClient {
       static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials) {
             // here your code
        }
    }
}

I hope this resolves your problem.
Miguel Lacouture

@mlacouture mlacouture changed the title Timeout issue? Timeout issue? (how to configure web service client). Jan 26, 2018
@zhenlan
Copy link
Member

zhenlan commented Feb 2, 2018

@lerudiconsulting, please let us know if you need anything else. Closing for now.

@zhenlan zhenlan closed this as completed Feb 2, 2018
@ttugates
Copy link

ttugates commented Feb 5, 2018

@lerudiconsulting , I am having the same issue. Were you able to increase your timeout inside ConfigureEndpoint as mentioned by @zhenlan ? If so would you mind sharing full solution? Thx..

@mlacouture
Copy link
Member

@lerudiconsulting, did you try setting the timeouts exposed by the System.ServiceModel.Description.ServiceEndpoint.Binding property inside the ConfigureEndpoint method?

@ttugates
Copy link

ttugates commented Feb 5, 2018

I tried this without success:

using System;
namespace AutoFluent.WorkbooksDataSvc
{
    public partial class WorkbooksDataClient
    {
        static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials)
        {
            serviceEndpoint.Binding.OpenTimeout = TimeSpan.MaxValue;
            serviceEndpoint.Binding.CloseTimeout = TimeSpan.MaxValue;
            serviceEndpoint.Binding.SendTimeout = TimeSpan.MaxValue;
            serviceEndpoint.Binding.ReceiveTimeout = TimeSpan.MaxValue;         
        }
    }
}

Are there other timeout properties I am missing? In issue #2368 @mconnew has a solution with a gist.
Setting WinHttpHandler Properties.
...

            // Fix the timeouts
            newHandler.ReceiveHeadersTimeout = Timeout.InfiniteTimeSpan;
            newHandler.ReceiveDataTimeout = Timeout.InfiniteTimeSpan;
            newHandler.SendTimeout = Timeout.InfiniteTimeSpan;

@mlacouture
Copy link
Member

Hi @ttugates. Yes, I would expect that to work (no need for the WinHttpHandler timeouts. What error do you get?

@ttugates
Copy link

ttugates commented Feb 5, 2018

I get:
exception.Messge = "An error occurred while sending the request."
exception.InnerException.Message = "An error occurred while sending the request."
exception.InnerException.InnerException.Message = "The operation timed out"

Right around the 31 sec mark of starting the request.

@zhenlan
Copy link
Member

zhenlan commented Feb 5, 2018

@ttugates, the code you have is fine. I think you hit the runtime bug #2368. You can try to work around the issue as @mconnew suggested for now. The issue is already fixed in next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling An issues related to any tool shipped from this repo.
Projects
None yet
Development

No branches or pull requests

4 participants