Sunday, May 27, 2018

A proper way to use HttpClient

Hello, I am building a little project of mine to scrape website that's built on JSF viewstates and scraping single information requires about 6 requests for that reason (If I understand it correctly). If the whole program runs on a single thread it runs abruptly long and stalls for quite some time after let's say 20 requests, If I do it multithreaded it's not working. I am currently trying to debug it but when I was wandering through the internet I found two approaches of how to use the HttpClient in a proper that are totally different.

Here is the first one: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

Second one: https://www.codeproject.com/Articles/1194406/Using-HttpClient-as-it-was-intended-because-you-re

Basically, do you dispose HttpClient after each request or not? If I do understand it correctly, in my case it would be better to keep one instance of HttpClient per thread?

A proper way to use HttpClient Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team