algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
177 stars 45 forks source link

Unreachable hosts Error #164

Closed martinholecekmax closed 2 years ago

martinholecekmax commented 2 years ago

Hello,

I have the following error after adding 30,000 new records when I run the gatsby build. It works fine with about 1,000 records but does not shows that error after uploading more data. I've contacted Algolia support, and they told me to create an issue here.

Unreachable hosts error screenshot

bdenham commented 2 years ago

I’ve been getting this exact error as well. Here’s my plug-in config:

    {
      resolve: `gatsby-plugin-algolia`,
      options: {
        appId: process.env.GATSBY_ALGOLIA_APPLICATION_ID,
        indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME,
        apiKey: process.env.ALGOLIA_WRITE_API_KEY,
        queries: indexAlgoliaRecords(),
        chunkSize: 10000,
        mergeSettings: false,
        settings: GLOBAL_INDEX_SETTINGS,
        enablePartialUpdates: false,
        matchFields: ['contentDigest'],
        concurrentQueries: false, // default: true
        dryRun: isDryRun, // default: true. When false, a new index is pushed to Algolia.
        continueOnFailure: true, // default: false. But we want `true` because the plugin will skip indexing but continue the build if the appId, apiKey, or indexName is missing
      },

I’ve tried several remedies, such as reducing the chunkSize to 1000, but nothing seems to work. And I’m getting this error when indexing less than 1,000 records, so I’m not sure it’s necessarily the size of the indexing that’s the issue.

It would be good to compare configs and other related settings with others that may also be seeing this error when trying to push records to indexes from their local workstations.

martinholecekmax commented 2 years ago

I've found the fix by increasing the timeouts in the gatsby config. Here is the setting I've used.

    resolve: `gatsby-plugin-algolia`,
    options: {
      appId: process.env.ALGOLIA_APP_ID,
      apiKey: process.env.ALGOLIA_ADMIN_KEY,
      queries,
      chunkSize: 1000, // default: 1000
      algoliasearchOptions: {
        timeouts: {
          connect: 20,
          read: 60,
          write: 60,
        },
      },
    },
  }
Haroenv commented 2 years ago

Could it be that your Gatsby host is physically far away from the Algolia host, and thus causing the indexing to take longer? Are your records large?

bdenham commented 2 years ago

@Haroenv, yeah I think you're right, I'm indexing from my local workstation in Austin, Tx and it looks like the Algolia hosts are somewhere in Europe. The records are not large. They are an average of 1-2K each. So it looks like it may be the distance from the servers coupled with my home internet upload speeds ranging anywhere from 15 - 50 Mbps...not great.

@martinholecekmax, thanks! I saw the algoliasearchOptions in passing while reading more of the Algolia docs, so I will definitely try that next. This issue is definitely making sense now that you guys mentioned the distance and speed factors at play. Making changes now and will post back results soon.

Haroenv commented 2 years ago

That makes sense, for now I'll close this issue as the solution is separate from this plugin. Please contact support if you have other connection problems

bdenham commented 2 years ago

@Haroenv and @martinholecekmax All good now! Thanks guys! Much appreciated!