jprichardson / node-google

A Node.js module to search and scrape Google.
MIT License
455 stars 115 forks source link

app completly crash and server restarted sometimes #43

Open cyclops24 opened 8 years ago

cyclops24 commented 8 years ago

Hi @jprichardson , First thanks for this awesome project. But I have a small issue with this module in Meteor. When I try to use proxy in request option sometimes for some proxy my app restarted and crash completely with following error:

W20160607-14:55:35.706(4.5)? (STDERR) events.js:72
W20160607-14:55:35.707(4.5)? (STDERR)         throw er; // Unhandled 'error' event
W20160607-14:55:35.707(4.5)? (STDERR)               ^
W20160607-14:55:35.710(4.5)? (STDERR) Error: read ECONNRESET
W20160607-14:55:35.710(4.5)? (STDERR)     at errnoException (net.js:905:11)
W20160607-14:55:35.711(4.5)? (STDERR)     at TCP.onread (net.js:559:19)
=> Exited with code: 8

This is my code:

google.requestOptions = {
            proxy: proxy,
            timeout: 3000
        };
        google.resultsPerPage = 50;

        let syncGoogle = Meteor.wrapAsync(google);

        let googleResult;
        try {
            googleResult = syncGoogle(keyword);
            for (let i = 0; i < googleResult.links.length; ++i) {
                // some process on result.
            }
        }
        catch (error) {
            console.error("error: " + error);
        }

Can you help me to fix this?