In Linux how do you set it that Google Chrome runs in debugging mode by default - node.js

I specifically need this for puppeteer to open a window in my current browser so that my user data can be accessed and I can login to places automatically
In Windows, you enable the setting by adding this to the shortcut icon's 'target' field, '–remote-debugging-port=9222'
This will automatically run Chrome with that setting so you have all your login sessions available
How can I have the same effect in Linux where I enable the setting permanently?
There is a way to run Chrome in this way by running /usr/bin/google-chrome-stable --remote-debugging-port=9220 in your terminal, but where can I edit a file to have this permanently enabled?
I've also run into a small error right now trying to start my puppeteer script.
FetchError: Failed to fetch browser webSocket URL from http://localhost:9222/json/version: request to http://localhost:9222/json/version failed, reason: connect ECONNREFUSED 127.0.0.1:9222
at ClientRequest.<anonymous> (/home/me/Coding/whatsapp-bot-puppeteer/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (node:events:526:28)
at Socket.socketErrorListener (node:_http_client:442:9)
at Socket.emit (node:events:526:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
type: 'system',
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED'
}
I'm Linux noob, so I need some help please ^-^

I have found a slight workaround, but it does require you to create a chrome instance through the terminal and then use a websocket connection string
You will also have to log into your new chrome window and sign in wherever
/usr/bin/google-chrome-stable --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=remote-profile
Running this in a Linux terminal will provide you with a ws connection you copy and then paste into your puppeteer script
Please look here for an example:
https://blog.nutjane.me/how-to-run-puppeteer-with-existing-chrome-profile-f42954bfc70c
You just have to make sure not to close this browser instance if you're planning on having a puppeteer script run the whole time. Otherwise you'll have to restart the chrome browser from the terminal and update the ws connection string in your puppeteer file :)
I've tested a quick script with puppeteer now, and I am having success with it :D

Related

aws-azure-login "Unable to recognize page state!"

I have trawled the net on this one and cannot find a resolution.
I have deployed an EC2 instance from a AWS RHEL 8 AMI.
I have installed all the pre-requisites for aws-azure-login but cannot connect to my accounts over SAML. (https://github.com/sportradar/aws-azure-login)
The config file has been created with parameters. When running aws-azure-login it returns the username, I press enter and then it hangs for minutes and returns the following error:
Unable to recognize page state! A screenshot has been dumped to aws-azure-login-unrecognized-state.png. If this problem persists, try running with --mode=gui or --mode=debug
After running in debug i get the following output:
Logging in with profile 'default'...
Using AWS SAML endpoint https://signin.aws.amazon.com/saml
Error: Failed to launch the browser process!
[13527:13527:1220/050718.762168:ERROR:browser_main_loop.cc(1409)] Unable to open X display.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/usr/lib/node_modules/aws-azure-login/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
at Interface.<anonymous> (/usr/lib/node_modules/aws-azure-login/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
at Interface.emit (events.js:412:35)
at Interface.emit (domain.js:475:12)
at Interface.close (readline.js:530:8)
at Socket.onend (readline.js:254:10)
at Socket.emit (events.js:412:35)
at Socket.emit (domain.js:475:12)
at endReadableNT (internal/streams/readable.js:1334:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Node version = v14.18.2
Any pointers would be greatly appreciated.
Note: on Linux you will likely need to disable the Puppeteer sandbox
or Chrome will fail to launch:
aws-azure-login --no-sandbox
If not check Unable to open X display when trying to run google-chrome on Centos (Rhel 7.5)
I bumped into same issue on CentOS7
aws-azure-login --profile <profile_name> --no-prompt --no-sandbox --enable-chrome-network-service --no-verify-ssl
worked for me, hope I helped anyone
I was getting the same error but then I end up recreating a new profile name. This time, I made sure that my profile name was one word, all lower case, and only characters was used. Example: automation

mediawiki - parsoid http:401 log in required

I am trying to install visual plug in for my wiki.
during installation i marked nearly all plugins and the result is all available after start.
But i can not save a page via visual.
Because parsoid did not started after installation.
So i decided to install parsoid my self via npm.
I started parsoid now the problem is:
Error contacting the Parsoid/RESTBase server (HTTP 401)
at the same time on the parsoid termina i see the following lines:
at Request._callback (C:\Users\baran\node_modules\parsoid\lib\mw\ApiRequest.js:332:35)\n at Request.self.callback (C:\Users\baran\node_modules\parsoid\node_modules\request\request.js:185:22)\n at Request.emit (events.js:315:20)\n at Request. (C:\Users\baran\node_modules\parsoid\node_modules\request\request.js:1157:10)\n at Request.emit (events.js:315:20)\n at IncomingMessage. (C:\Users\baran\node_modules\parsoid\node_modules\request\request.js:1079:12)\n at Object.onceWrapper (events.js:421:28)\n at IncomingMessage.emit (events.js:327:22)\n at endReadableNT (_stream_readable.js:1327:12)
\n at processTicksAndRejections (internal/process/task_queues.js:80:21)","httpStatus":401,"levelPath":"fatal/request"},"msg":"Your
wiki requires a logged-in account to access the API.","time":"2020-11-17T16:21:29.965Z","v":0}
So the critical line is:
Your wiki requires a logged-in account to access the API
I have installed wiki and parsoid separately how could i enable parsoid to login to the wiki ? ?
Thanx
It is not the correct solution but it is possible to set wiki as "not private" so no need for login for parsoid, and you can protect pages that you don't want other users to modify.

nodejs twitter api in docker container throw 401 error

I am working on a nodejs twitter api and it's working perfectly fine in the local env but when I try to containerize, it fails with a 401 error from twitter.js which is "HTTP 401 Unauthorized client error status response code".
Error
> node app.js
Error: Status Code: 401
at Request.<anonymous> (/usr/src/app/node_modules/twitter/lib/twitter.js:277:28)
at Request.emit (events.js:315:20)
at Request.onRequestResponse (/usr/src/app/node_modules/request/request.js:1059:10)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:117:17)
at TLSSocket.socketOnData (_http_client.js:472:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:273:9)
I did my search on this where I found that this could a time mismatch issue in the docker container. My docker container is running 1 and a half hours behind the actual time. I am not sure if this is the only issue.
My docker file
FROM node:13.13.0-alpine
# Create app directory
WORKDIR /usr/src/app
COPY package*.json ./
# Bundle app source
COPY . .
ENV KAFKA_HOST=localhost:9092 \
KAFKA_TOPIC=tweetstream
CMD ["npm", "start"]
How can I set the right time in this docker image?
OAuth requires close time synchronisation, so that is very likely to be the issue, especially if your code works outside of the container in a system where the time is synchronised.
I am on a Windows host machine and as I mentioned in the question there was a time difference between my host and the containers.
What I did to resolve the time difference?
Search Hyper-V Manager -> Docker Desktop VM (seen on right bottom) -> Settings (new popup will open)
Management -> Integration services -> Time Synchronization (uncheck) -> Apply -> ok
Again go to the same location and check the Time Synchronization -> Apply -> ok
I also feel you will have to redo it once your windows machine goes into hibernation.
Reference articles: https://thorsten-hans.com/docker-on-windows-fix-time-synchronization-issue
https://www.ivankrizsan.se/2015/10/31/time-in-docker-containers/

Errror which crashed the my hosted node.js server file which is run on fore erver command

My node.js server file which is hosted on a server is used by my various applications like mobile apps and desktop app.
At some time my server file which is run through forever command crashes and my whole front end system goes down. Why does the server file crash?
Type Error: Cannot read property 'fragmentedOperation' of null
at Receiver.endPacket (C:\Users\root\Desktop\Server\windowsnodefiles\node-v6.10.3-win-x64\node_modules\socket\node_modules\ws\lib\Receiver.js:247:18)
at Receiver.finish (C:\Users\root\Desktop\Server\windowsnodefiles\node-v6.10.3-win-x64\node_modules\socket.io\node_modules\ws\lib\Receiver.js:483:12)
at Receiver.<anonymous> (C:\Users\root\Desktop\Server\windowsnodefiles\node-v6.10.3-win-x64\node_modules\socket.io\node_modules\ws\lib\Receiver.js:451:33)
at Receiver.add (C:\Users\root\Desktop\Server\windowsnodefiles\node-v6.10.3-win-x64\node_modules\socket.io\node_modules\ws\lib\Receiver.js:95:24)
at Socket.realHandler (C:\Users\root\Desktop\Server\windowsnodefiles\node-v6.10.3-win-x64\node_modules\socket.io\node_modules\ws\lib\WebSocket.js:800:20)
at emit One (events.js:96:13)
at Socket.emit (events.js:188:7)
at readability (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Nonreactive (net.js:547:20)
error: Forever detected script exited with code: 1
error: Script restart attempt #2
Error: %1 is not a valid Win32 application.
If you are using browserSync library then you can check this link
rollback the browserSync version to ^2.6.4 and it works
or try updating your socket.io package as per this link
Please check if your issue is fixed with the latest release

Remote access to IIS-express

Usually when I start my web application, the browser will open https://localhost:44305
But I want to reach the site from my phone. I've tried changing the applicationhost configfile, firewall inbound rules and all that. But then I found this little thing iisexpress-github
I type this in my console: iisexpress-proxy https://localhost:44305 to 3005
Which results in this line: Proxying https://localhost:44305 to network interfaces:
Ethernet: 192.168.10.41:3005
Listening... [press Control-C to exit]
After following instructions, the browser gives following error: 'Aw snap! Something went wrong. Check your console to see the error.'
And then I look at my console which says the following:
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1016:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:585:8)
Usually my site is https, but this seems only to proxy to normal http.
What to do?

Resources