tinify / tinify-nodejs

Node.js client for the Tinify API.
https://tinypng.com/developers
MIT License
421 stars 74 forks source link

Error while connecting: getaddrinfo ENOTFOUND api.tinify.com api.tinify.com:443 #8

Closed amsdamsgram closed 7 years ago

amsdamsgram commented 7 years ago

Hey,

I'm trying to use tinify with Could Functions for Firebase but I'm getting the following error:

Error: Error while connecting: getaddrinfo ENOTFOUND api.tinify.com api.tinify.com:443
    at ConnectionError (/user_code/node_modules/tinify/lib/tinify/Error.js:38:1)
    at ClientRequest.request.on.err (/user_code/node_modules/tinify/lib/tinify/Client.js:99:18)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at connectErrorNT (net.js:1020:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

I use it like this:

new Promise((resolve, reject) => {
        tinify.fromFile(tempLocalFile).toFile(tempLocalFile);
        resolve(tempLocalFile)
      }).then((newFile) => console.log(newFile))

(I'm also trying to use it as a Promise but it doesn't seem to work. I'm getting the console.log before the error with tinify)

I'm thinking this is a proxy error? But I'm not sure.

Thanks for your help!

rolftimmermans commented 7 years ago

Is it possible that you are on the "Spark" plan? According to https://firebase.google.com/pricing/ – "The Spark plan only allows outbound network requests to Google owned services."

This would explain the behaviour you are seeing.

If you are using another setup, feel free to comment and reopen the issue.

amsdamsgram commented 7 years ago

Good catch! I'm on the Spark plan. Thanks for the fast reply!