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!