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

Fix / Add a timeout to avoid hanging requests #403

Merged
merged 3 commits into from Dec 7, 2019

Conversation

@paulodiovani
Copy link
Contributor

paulodiovani commented Dec 4, 2019

Some websites may fail to respond to the requests at all, as a result the process will be stuck, a simple solution is to set a timeout, as supported by the requests module.

Changes in this pull request

  • Add a fixed timeout to all requests (currently set to 10s)
    Note: In my tests, 10s was enough even with Tor. Sometimes a site may take longer to respond, but a longer timeout will make the script takes to much time (waiting + retries) and the retries will usually handle intermittent connections.
  • Change Flipboard unclaimed username
  • Add a tests/.excluded_sites list to allow pass tests for unresponsive sites

Fixed issues

This PR shall fix these issues.
It would be nice if the reporters could check if they still persist.

@sdushantha sdushantha requested a review from hoadlck Dec 4, 2019
@sdushantha
Copy link
Member

sdushantha commented Dec 4, 2019

Everything looks good to me 👍
@hoadlck can you double check?

@sdushantha
Copy link
Member

sdushantha commented Dec 4, 2019

@paulodiovani By the way, I really appreciate the detailed and well written PR. It is very easy to understand :)

@paulodiovani paulodiovani force-pushed the paulodiovani:fix/timeout-requests branch from f19c95b to 07c3fc3 Dec 4, 2019
@hoadlck
Copy link
Collaborator

hoadlck commented Dec 5, 2019

What is the goodness of tests/.excluded_sites? If a site is not responding, then we need to remove it. I do disable selective sites sometimes during testing, but I just edit the data.json. But, I guess it may be a preference thing.

As far as the change to the tests goes, the load of the tests/.excluded_sites is not in the correct place. It should be loaded in the setUp() method, and used to set an attribute of the SherlockBaseTest() class. As it is, every sub-test is going to be hitting the file system, while the information is not going to change.

@paulodiovani
Copy link
Contributor Author

paulodiovani commented Dec 5, 2019

@hoadlck
data.json is versioned, and sometimes a site will fail due to local connection instability (a backbone down, a weird configured proxy, etc) so I think its easier to have a simple text file with a site per line for that without the risk of committing data.json changes by mistake.

I'll do the changes you requested and move the file read to setup.

@paulodiovani paulodiovani force-pushed the paulodiovani:fix/timeout-requests branch from 07c3fc3 to e243399 Dec 5, 2019
@torerobo
Copy link

torerobo commented Dec 7, 2019

Some websites may fail to respond to the requests at all, as a result the process will be stuck, a simple solution is to set a timeout, as supported by the requests module.

Changes in this pull request

  • Add a fixed timeout to all requests (currently set to 10s)
    Note: In my tests, 10s was enough even with Tor. Sometimes a site may take longer to respond, but a longer timeout will make the script takes to much time (waiting + retries) and the retries will usually handle intermittent connections.
  • Change Flipboard unclaimed username
  • Add a tests/.excluded_sites list to allow pass tests for unresponsive sites

Fixed issues

This PR shall fix these issues.
It would be nice if the reporters could check if they still persist.

Yes, the patch works successfully. I confirm.

@hoadlck hoadlck merged commit e243399 into sherlock-project:master Dec 7, 2019
@hoadlck
Copy link
Collaborator

hoadlck commented Dec 7, 2019

In regards to the timeout of 10.0s...in my test setup, I get many timeout errors even increasing the timeout up to 90s. My connection is not that terrible, so I don't think that 10s is a good number.

In addition to this, we should not be using any global variable in Sherlock. I know that there are some now: this is one of the pains that I am having in doing the restructuring.

I decided to make the timeout a command line option. By default, the timeout will be disabled (just as it was before). But, a user can specify something shorter if they like.

I think that there are performance problems with some of the sites that have been added recently. If that keeps up, they are going to have to be pruned.

I am also seeing anomalies in how the timeout functions. When I set the timeout to 90s, I get completion times of less than that, with multiple error connecting problems. I think that there is something more basic causing problems: probably a manifestation of the problem noticed in #323. I am thinking that the naive way that Sherlock spawns a thread for all sites at the beginning of the query is overwhelming people's computers. We now have enough sites that we are hitting this limit.

This is something I am working on in the restructuring.

Copy link
Collaborator

hoadlck left a comment

Merged it.

@torerobo
Copy link

torerobo commented Dec 8, 2019

The "time delay" patch works for me successfully, but after a few times I get multiple "connection errors".

Maybe it is better to add "exclusion of bad sites" to cli? For example,

python3 sherlock --bad piling telegram

@hoadlck
Copy link
Collaborator

hoadlck commented Dec 8, 2019

No: if we have bad sites, they need to be pruned. I think that many of the recently added sites have slow response. I did not have time to look into it yesterday, but I hope to today.

@torerobo
Copy link

torerobo commented Dec 8, 2019

Mmm, I don’t know how else to explain. The "pling" site is not bad, but it does not work in the ru location (3000000 ip addresses are blocked in the ru location) and sherlock stumbles on it. And in China, for example, perhaps half of the list does not work, but this does not mean that the site is bad.

@MinePro120
Copy link

MinePro120 commented Dec 13, 2019

I'm a little late, but it works fine now, yes. Issue closed.

@paulodiovani paulodiovani deleted the paulodiovani:fix/timeout-requests branch Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.