0

I can run the following code on my laptop successfully with public wifi.

const {Logging} = require('@google-cloud/logging');


let storageOptions = {
  projectId: 'project-01',
  keyFilename: 'mykey-c4426ff28f95.json'
};

const logging = new Logging(storageOptions);

  const options = {
    filter: 'resource.type="global" timestamp >= "2019-09-12T14:41:40+08:00"'
  };

async function getLog(){

    const [entries] = await logging.getEntries(options);

      entries.forEach(entry => {
        const metadata = entry.metadata;
        console.log(`${metadata.timestamp}:`, metadata[metadata.payload]);
      });
    return 'success';
}
getLog().then(msg=>{console.log(msg);process.exit(0);}).catch(err=>{
    console.log('list file error: '+err);
    process.exit(1);
});

But when I put the same code on my company server to run, it was pending and no response.

I think it is a proxy issue, so that I have tried to solve it by the following methods:

Runtime with proxy

https_proxy="http://proxy.mycompany.com:8000" node testLogging.js

Set environment variable

export https_proxy="http://proxy.mycompany.com:8000"

Unfortunately, both of the above cannot solve the issue, and I cannot find the answer on Google.

p.s. I have tried wget command on my company server, the API return 403 response, so that I assume the proxy is working fine.

wget -e use_proxy=yes -e https_proxy=proxy.mycompany.com:8000 -O test.html --no-check-certificate --post-data '' https://logging.googleapis.com/v2/entries:list

Please suggest how to call Logging API behind the proxy server.

Thanks!

Harif Velarde
  • 733
  • 5
  • 10
F Leung
  • 1
  • 2
  • Hello, I think is not a proxy problem since error 403 is related to permissions, you can reach the service with the request but maybe the user you are using doesn't count with the properly credentials, can you share the complete trace of the error message? – Harif Velarde Sep 24 '19 at 14:56
  • I wonder the issue is due to nodejs @google/logging library hasn't supported proxy yet. – F Leung Sep 25 '19 at 09:15
  • I think you can take a look on this document where is explained how to use the Stackdriver Logging from any place: https://cloud.google.com/logging/docs/setup/nodejs#run-local – Harif Velarde Sep 27 '19 at 22:23

0 Answers0