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

Error requesting Google Play: Client network socket disconnected before secure TLS connection was established #628

Open
datehoer opened this issue Apr 12, 2023 · 0 comments

Comments

@datehoer
Copy link

Operating System:
Windows 10

Node version:
16.16.0

google-play-scraper version:
^9.1.1

Description:
I encountered a network problem while making a request using google-play-scraper. Even after wrapping the request in a try-catch block, the function could not continue working.
The error message I received was:

Error: Error requesting Google Play: Client network socket disconnected before secure TLS connection was established
    at D:\node_work\work\knowledge\googleplay\node_modules\google-play-scraper\lib\utils\request.js:41:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async scrapeGooglePlay (D:\node_work\work\knowledge\googleplay\google-play.js:35:26)
    at async main (D:\node_work\work\knowledge\googleplay\google-play.js:127:9) {
  status: undefined
}

Example code:

while(err<5){
  try {
      let proxy = new ProxyAgent(proxies[Math.floor(Math.random() * proxies.length)])
      let scrapingOptions = {
          appId: data["appId"],
          requestOptions: {
              retry: { limit: 0 },
              agent: {
                  https: proxy,
                  http: proxy,
                  http2: proxy,
              },
          },
          throttle: 5,
      }
      console.log("start")
      let result = await gplay.app(scrapingOptions)
      result["scrapedAt"] = moment().format("YYYY-MM-DD HH:mm:ss")
      data = Object.assign(data, result)
      await collection.updateOne(
          { appId: result.appId, version: result.version },
          { $set: result },
          { upsert: true }
      )
      console.log(`Inserted ${data.title} documents into ${dbName}.${collectionName}`)
      return ""
  } catch (e) {
      console.log("Error scraping data: ", e)
      err++
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant