Unable to establish one or more of the specified browser connections / Ubuntu / Firefox Headless - node.js

My setup:
OS: Ubuntu 18
Testcafe Version: 1.8.8
Browser: Firefox
I have several Ubuntu servers where Testcafe was working. Due to a security issue, I had to reinstall the servers entirely. Unfortunately in the fresh reinstall, Testcafe is saying it is unable to establish one or more of the specified browser connections. I have firefox installed and reconfirmed it was installed.
Previously I did this:
Issue command: sudo testcafe test.js
Expected behavior: After a moment, I could visibly see in the logs that the test was running using Firefox headless. Life was fine.
Now when I do the exact same thing in the fresh reinstall:
Issue command: sudo testcafe test.js
Unexpected behavior: After a moment, I get this in console:
Using locally installed version of TestCafe. ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
Bummer!
Here is the .testcaferc.json I am using:
{
"browsers": ["firefox:headless"],
"speed": 0.1,
"skipJsErrors" : true,
"pageLoadTimeout": 5000
}
When I run testcafe --list-browsers, I get:
firefox
My test file:
import { ClientFunction, Selector } from 'testcafe';
fixture `triage`
.page('https://www.google.com/');
test(`test debugging`, async t => {
await t
.wait(5000)
console.log(`I did it!`)
})
Previously there was no issue! Had I not had to reinstall Ubuntu, there would be no fail. I have actually 5 servers like this and really need a fix. Any ideas why this is happening?
I even installed chrome. Same issue! Failure to establish a connection to chrome too.

Finally this was solved for me. My solution, and what I did differently.
Previous install steps:
Install Ubuntu
Login as root
Create new user
Login to new user account
Install Node.js as sudo in new user account
Install Firefox as sudo in new user account
Install Testcafe as sudo in new user account
Setup git clone of express...
After days of looking at this I thought wait Unable to establish one or more of the specified browser connections may just mean Can't see the browser due to being installed as sudo in a user account thus unable to establish that browser connection... (like it can't see it for some reason).
To test this theory, I rearranged the install steps and suddenly everything worked!
Here are the steps that solved this issue for me:
Install Ubuntu
Login as root
Install Node.js AS ROOT
Install Firefox AS ROOT
Install Testcafe AS ROOT (this allows you to do npm i -g testcafe as well as being able to issue the command testcafe "firefox:headless" mytest.js -e instead of sudo testcafe "firefox:headless" mytest.js -e, which doesn't work with sudo well)
Create new user
Login to new user account
Setup git clone of express...
Now all my requests are triggering the tests as before.

Related

Puppeteer won't start

code is hanging on this line, works fine when run as root user
const browser = await puppeteer.launch({args:['--no-sandbox']});
I uninstalled node_modules and reinstalled as the user running the command.
I tried adding the user to sudo
I think its permission issue but not sure what
Fixed this by updating node (v12), installing server updates and restarting *sigh

React: npm start - windows cannot find localhost

I am trying to follow tutorials for basic react-build-app.
ENVIRONMENT
I am using Ubuntu on Windows 10.
Node version: v13.3.0
NPM version: 6.13.1
So far I did,
npm install -g create-react-app
create-react-app calculator
cd calculator
npm start
PROBLEM
When I run npm start, I get pop up dialog from windows saying, Windows cannot find '\https://localhost:3000/\'. Make sure you typed the name correctly, and then try again.
Here is a screenshot of the error
However, in the cli, I see
Local: http://localhost:3000/
On Your Network: http://192.168.56.1:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.```
But when I open my browser and go to http://localhost:3000/, I only see a blank page, and not the normal React logo.
EXPECTED OUTPUT
I should see the react logo when going to http://localhost:3000/, and not receive and error.
ATTEMPTS
Updated nodejs and npm.
Changed ports using package.json. Also tried
using .env file to change port. Same error.
Uninstalled and re-installed ubuntu 18.04 LTS and used NVM to install nodejs and npm.
WORKAROUND
I got tired of fixing error after error with linux, so I just set up npm and nodejs on windows instead. ran create-react-app on windows cli and it worked the first time. Told me something else was listening on the port i was trying to open, so prompted me to change port. I said yes. Now I get the landing page I was looking for.
I am very new at this and have been trying to figure this out for a couple days now, I would appreciate any advice. Thank you.
This is a WSL specific issue with one of the dependencies of react-scripts, more specifically open version 7.0.0.
To resolve, you can:
switch to react-scripts 3.2.0 in your package.json, or
run npm start from something else than WSL (e.g. Powershell), or
wait for open and react to fix the issue
Bug report in React Scripts:
https://github.com/facebook/create-react-app/issues/8081
And the corresponding bug report in open:
https://github.com/sindresorhus/open/issues/154
According to this post in the bug report in open the culprit is lines 76 & 77 of index.js in node_modules/open. If you comment them out then it works fine.
Link to comment:
https://github.com/sindresorhus/open/issues/154#issuecomment-562509596

Phonegap serve Ubuntu 17 not working/exiting silently

Using ubuntu 17. Firewall is completely disabled using sudo ufw disable
Ive sudo npm -g install phonegap and created a project using sudo phonegap create.
From this stock created project i try to sudo phonegap serve, the terminal is still for 2 seconds then the command exits silently with no error message.
I have also tried cordova and have done the exact same steps
install create serve, I get further the application seems to serve. I can get on the website and on the browser of my phone and can see the project directory. When I get on the phonegap developer app to check the project out, I enter my laptops ip and port, I seem to get through but the app responds with "Unable to download archive from server" and on the serve console I get a 404 /__api__/appzip.

Errors installing socket.io for node.js

I installed node on my windows 8 machine with no problems and then went to install the socket.io package to use for an assignment. After typing
npm install socket.io
I got a huge amount of errors.
What I've tried so far:
this - nodejs npm install socket.io error
and this - NPM - Can't install socket.IO
The first answer in both.
A lot of the other stuff I'm finding is for either windows 7 or Mac so I'm not sure if this is just a windows 8 thing.
As you can see in logs you have a permission error. Script doesn't have enough permissions to create directory in C:\\Program_Files\.... Use other directory instead or run command with Admin permissions.
Try running
npm install socket.io
except this time run the command line as an administrator. You can do this in Windows 8 by going to your app search, typing cmd, right-clicking then click 'Run as administrator'.
I feel this is the issue because your error message says 'Please try running this command again as root/Administrator'.

Build Meteor in Docker cannot pass proxy setting

I use latest Nodejs image as base image to build meteor project. The docker is behind the corporate proxy.
I tried curl and npm install -g. Both of them can go through the proxy and download packages.
However, when I try to use meteor update, error prompts as:
Unable to update package catalog (are you offline?)
=> Errors while upgrading packages:
error: tunneling socket could not be established, cause=socket hang up
Then the next step is using run meteor build, and I sometimes also got the error as
error: tunneling socket could not be established,
cause=140434436118336:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:795:
I test the proxy setting by echo it before I ran meteor command. It shown correctly.
Can anyone help? There is an bug fixes in meteor states that meteor can use http_proxy setting. https://github.com/meteor/meteor/commit/3177d9ad416ae97a98a2b8c4b2b40a9fc03f6b9c
I've actually found this to be an issue that occurs with docker across a couple of projects and solve it by simply restarting my docker machine (working on OSX)
$ docker-machine restart dev
Also Meteor doesn't support the more recent versions of node due in part to complexities associated with Fibers, you'll probably want to build your container FROM node:0.10.40

Resources