Hi can someone help to figure out how to successfully execute the following puppeteer.connect behind the proxy ?
Thx.
await puppeteer.connect({
browserWSEndpoint: "wss://cdp.lambdatest.com/puppeteer?capabilities=xxxxx",
})
Related
I try to deploy one gcloud function with the below Github link to back up the datastore.
https://github.com/portsoc/cloud-simple-datastore-backup/blob/master/index.js
After updating the variant BUCKET_NAME with my cloud storage bucket name, I run it under gcloud shell with the command: node index.js and it will backup the datastore successfully.
but when I continue to run the below command to deploy it:
gcloud functions deploy main
--runtime nodejs12 --trigger-http --allow-unauthenticated
--region=asia-southeast2
After a while, it will give me the below error:
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Click to view the error screenshot
Any suggestion on this?
Cloud Functions have a specific set of signatures that must be used.
I'm less familiar with JavaScript|Node.JS but I think the function you reference is intended to be invoked as you do node index.js (or similar) and this is incompatible with Cloud Functions.
Please review Write Cloud Functions to understand that signature type that you will need. You will probably have to tweak the authentication in the example to better meet your needs too.
Almost certainly you don't want --allow-unauthenticated either.
After changing the upload code below, I can deploy it.
const { GoogleAuth } = require("google-auth-library");
// fill in your bucket name here:
const BUCKET_NAME = "gs://testinbbk10";
exports.myfunction = async (req,res) =>{
try {
const auth = new GoogleAuth({
scopes: "https://www.googleapis.com/auth/cloud-platform",
});
const client = await auth.getClient();
const projectId = await auth.getProjectId();
console.log(`Project ID is ${projectId}`);
const res2 = await client.request({
method: "POST",
url: `https://datastore.googleapis.com/v1/projects/${projectId}:export`,
data: {
outputUrlPrefix: BUCKET_NAME,
},
});
console.error("RESPONSE:");
console.log(res2.data);
} catch (error) {
console.error("ERROR");
console.error(error);
}
}
but when I try to access the provided link: deploy link, it will show me the error: could not handle the request.
I am confused about how to properly deploy this to the google cloud function? Just want to deploy one simply google cloud function to backup datastore in the google cloud.
I have two containers, one Puppeteer and one Browserless. I try to connect to Browserless, but it fails. Both containers are in the same network.
Here is my code:
await puppeteer.connect({
browserWSEndpoint: "wss://browserless:3000"
});
Websocket secure, short wss was my issue. The following code works fine.
await puppeteer.connect({
browserWSEndpoint: "ws://browserless:3000"
});
how can i simulate the "PROTOCOL_CONNECTION_LOST" error in mysql for node.js?
If i get the error, my application crashes, and i dont know how to reproduce this error.
thank you.
it really sounds like your application is crashing because is not handling the error. You may want to check in the files where you initialize the MySQL connection if that's the case.
As for the error, the "PROTOCOL_CONNECTION_LOST" is just a Generic Error Object. If you want to throw it inside your application (not actually stopping MySQL from working):
const err = new Error('Connection lost: The server closed the connection.');
err.fatal = true;
err.code = 'PROTOCOL_CONNECTION_LOST';
throw err;
Put that in the line of code where you want to throw the error.
If you want to emulate that MySql is throwing this error, one (unrecommended way) is to hack into the lib. The Connections object has access to the Protocol object, which has a hidden method _delegateError that's the one fired when there's a protocol error. Source: https://github.com/mysqljs/mysql/blob/master/lib/protocol/Protocol.js
Here is solution for connection protocol lost. This solution solved me
Here the data base connection
const mysql = require('mysql');
const connection=mysql.createConnection({
host:'localhost',
user:'root',
password:'******',
database:'db_name'
});
connection.connect(function(error){
if(!!error) console.log(error);
else console.log('SQL Database Connected!');
});
module.exports = connection;
`
just run the node server using pm2
Ex. pm2 start app.js
install the npm pm2 package
After two weeks of trying to run my site, I'm asking for your help.
Has anyone hosted Sails.JS on PlanetHoster?
My queries don't work because the connection to the database doesn't seem established.
Here's an example of some very simple queries:
await User.findOne({ email: email });
Here's what's displayed in the browser error console:
Uncaught (in promise) Error: Request failed with status code 500
I've tried to handle the errors but nothing is displayed...
try { await User.findOne({ email: email }); } catch(err) { // nothing }
So I've deduced that it was a problem with calling the database.
Unfortunately, I have no way to read the error logs ...
Yet, I've set the production.js file (config/env/production.js) and when I run NODE_ENV = production node app.js, it's still displayed in development. In fact, PlanetHoster doesn't require running the command sails lift, it just runs the platform already ...
I'm currently in a total blur as for where to go from here so if you have suggestions, I will take them with pleasure.
Thank you
Environment: Sails v1.0.2
So, I've developed a website (HTML) that has an embedded payment form from Stripe called Checkout. When you visit the website, it prompts you to enter your credit card information, so the checkout form is working correctly.
The issue I'm having is processing the token once it's created.
I'm extremely new to web development and I've never written server code before so please, bear with me.
I've been following guides (Process payments with Node, Vue, Stripe & How to set up Stripe payments with Node.js) and stripes documentation on tokenization to create charges using server-side code (Stripe Checkout)
I understand that I have to have Heroku set up to process the charges so I created an account and set up an app from my terminal. I made a new directory that has the modules required (stripe, express, and bodyParser) and I have this code in my server.js file:
It deploys to Heroku successfully but crashes. This is what is being returned in the console:
What am I doing wrong? Any assistance would be a great help.
You are missing a vital piece:
// Start the server
app.listen(port, function(){
console.log('Server listening on port ' + port)
});
You don't seem to start the server in your application. This should be in the bottom of server.js. You also have to remember to set the port:
var port = process.env.PORT || 3000;
It goes above app.listen of course.
I can't tell for sure if that will fix all your errors, but you have to start with starting the server first.
Also, remember to check for errors in callbacks. In the callback for create you are not doing that. E.g.
if (err){
console.error(err);
res.json({ error: err, charge: false });
} else {
// send response with charge data
res.json({ error: false, charge: charge });
}
You are doing res.send() whether or not there are errors. I doubt that this has anything to do with the Heroku error though.