Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: getaddrinfo EAI_AGAIN api.spotify.com:443

While I am in a process of integrating Spotify API into Google Assistant app, implementing Account Linking,

getaddrinfo EAI_AGAIN api.spotify.com:443

This above error has been kept coming out in the console, although it seems to be working like nothing is wrong around API implementation. The access token is properly created and received and client and secret ids were filled without any typo. Also, I tested API calls on Spotify Console (https://developer.spotify.com/console/get-artist-albums/). No error was found. It fetched expected data from the Spotify server, so it should not be related to Account Linking and Spotify Server. The created code myself is below: I assume there is something wrong around spotify-web-api-node, node, npm, or firebase-functions?? I recently have done node versioning so I might did something wrong.

  • Node version: v7.9.0
  • spotify-web-api-node: ^4.0.0
  • firebase-functions: ^2.0.3
  • npm version: 6.4.1
  • Added engines: { "node": "8" } // this is in package.json to use asyn and await

app.intent(SomeIntent, async (conv, params) => {
    console.log('user info', JSON.stringify(conv.user));
    conv.ask('lets play'); //okay
    const access_token = conv.user.access.token || ''; // okay
    console.log('Your TOKEN information here: ' + access_token); // okay
    spotifyApi.setAccessToken(access_token); // should be set correctly
    let data = await findMusic(); // error in the findMusic func
    conv.ask('found this song。', data.name); //  so no data.name
});

function findMusic() {
    return spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE').then((data) => {
        console.log('artist song', data.body);
        return data.body; //this does not return because error is produced
    }).catch(err => {
        console.log('Something went wrong!', err);
        return err; // this error is WebapiError: getaddrinfo EAI_AGAIN api.spotify.com:443
    });
}

UPDATE

@Nick-Felker mentioned in the comment below that external calls are allowed only through paid plans. So this might be the solution (not proved to be working right now because I am not using a paid plan. The detailed explanation below is quoted from An answer comment from another StackOverflow post

The Spark plan allows outbound network requests only to Google-owned services. Inbound invocation requests are allowed within the quota. On the Blaze plan, Cloud Functions provides a perpetual free tier. The first 2,000,000 invocations, 400,000 GB-sec, 200,000 CPU-sec, and 5 GB of Internet egress traffic is provided for free each month. You are only charged on usage past this free allotment. Pricing is based on total number of invocations, and compute time. Compute time is variable based on the amount of memory and CPU provisioned for a function. Usage limits are also enforced through daily and 100s quotas. For more information, see Cloud Functions Pricing.

UPDATE

In my case, the above solution worked. Hope this article helps others!

like image 254
Ryohei Avatar asked Nov 08 '22 00:11

Ryohei


1 Answers

I got this error due to network problem. And solved when connected

like image 180
Sanjaya Bir Bikram Shrestha Avatar answered Nov 15 '22 07:11

Sanjaya Bir Bikram Shrestha