Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

WebClient timeout

    private class WebClient : System.Net.WebClient
    {
        public int Timeout { get; set; }

        protected override WebRequest GetWebRequest(Uri uri)
        {
            WebRequest lWebRequest = base.GetWebRequest(uri);
            lWebRequest.Timeout = Timeout;
            ((HttpWebRequest)lWebRequest).ReadWriteTimeout = Timeout;
            return lWebRequest;
        }
    }

    private string GetRequest(string aURL)
    {
        using (var lWebClient = new WebClient())
        {
            lWebClient.Timeout = 600 * 60 * 1000;
            return lWebClient.DownloadString(aURL);
        }
    }
Comment

webclient timeout

@Configuration
@EnableWebFlux
public class WebFluxConfig implements WebFluxConfigurer
{  
  Logger logger = LoggerFactory.getLogger(WebFluxConfig.class);
   
  @Bean
  public WebClient getWebClient()
  {
    HttpClient httpClient = HttpClient.create()
            .tcpConfiguration(client ->
            		// Here there are global timeout
                    client.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
                    .doOnConnected(conn -> conn
                            .addHandlerLast(new ReadTimeoutHandler(10))
                            .addHandlerLast(new WriteTimeoutHandler(10))));
     
    ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient.wiretap(true));     
 
    return WebClient.builder()
            .baseUrl("http://localhost:3000")
            .clientConnector(connector)
            .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
            .build();
  }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity deactivate component 
Csharp :: c# how does comparing datetime work 
Csharp :: c# clear all textboxes 
Csharp :: c# return task list 
Csharp :: datatable linq where clause c# 
Csharp :: unity find child by name 
Csharp :: unity check gameobject active 
Csharp :: 2d list c# 
Csharp :: calculate how much memory an object take c# 
Csharp :: lcm of numbers 
Csharp :: website link c# 
Csharp :: how to add headers to scripts in unity 
Csharp :: c# string enum 
Csharp :: c# object list attribute to string 
Csharp :: file to byte array 
Csharp :: c# copy files from one folder to another 
Csharp :: get sha1 hashcode from c# 
Csharp :: c# excel workbook 
Csharp :: C# network traffic 
Csharp :: c# combobox add item 
Csharp :: c# wpf image source from resource programmatically 
Csharp :: c# get gridview DataKeyNames 
Csharp :: list min and Max value in c# 
Csharp :: how to make pc bsod C# 
Csharp :: All Possible SubString of string 
Csharp :: c# function 
Csharp :: .net core 6 autofac 
Csharp :: take space separated input in c# 
Csharp :: c# nullable generic 
Csharp :: c# get witdh of matrix 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =