. Advertisement .
..3..
. Advertisement .
..4..
As advised, I used some code samples in another forum but it could not improve the problem. My question is the “ client network socket disconnected before secure tls connection was established ” in programs- how to solve it? Command line is:
const {google} = require('googleapis');
const blogger = google.blogger({
version: 'v3',
auth: 'YOUR API KEY'
});
blogger.blogs.get({blogId: '3213900'}, (err, res) => {
if (err) {
console.error(err);
throw err;
}
console.log(`The blog url is ${res.data.url}`);
});
//But I can get result in browser https://blogger.googleapis.com/v3/blogs/3213900?key=xxx
var url = require('url');
var https = require('https');
var HttpsProxyAgent = require('https-proxy-agent');
// HTTP/HTTPS proxy to connect to
var proxy = 'my-vpn-proxy';
var endpoint = 'https://blogger.googleapis.com/v3/blogs/3213900?key=xxx';
var opts = url.parse(endpoint);
var agent = new HttpsProxyAgent(proxy);
opts.agent = agent;
https.get(opts, function (res) {
console.log('"response" event!', res.headers);
res.pipe(process.stdout);
});
and the result:
Client network socket disconnected before secure TLS connection was established
What does the message mean? Can you advise me to fix it? If you have other better answers, leave it in the answer box below.
The cause: Your proxy perhaps related to this error.
Solution: You can do the following process:
This will work fine but the permanent solution is to make sure that all software might be automatically set up proxy for you.
If you have the same problem as someone else, there is a solution.
This should work, but you need to ensure that you disable any software that may be setting up proxy services for you.