This error only happens when I spawn the ios-driver jar as a Node.js child.
The error is java.net.SocketException: Protocol family unavailable
selenium-test.js:
var spawn = require('child_process').spawn;
var selenium = spawn('java', ['-jar', './ios-server-standalone-0.6.6-SNAPSHOT.jar', '-port', '4444']);
selenium.stderr.setEncoding('utf8');
selenium.stderr.on('data', function (data){
console.log(data);
});
webdriverjs-test.js (webdriverjs)
var webdriverjs = require('webdriverjs');
var options = {
desiredCapabilities: {
browserName: 'safari',
platform: 'OS X 10.9',
version: '7.1',
device: 'iphone'
}
};
webdriverjs
.remote(options)
.init()
.end();
Reproduce this error by creating the above files, running selenium-test.js in one window and webdriverjs-test.js in another window. You will first need to npm install webdriverjs and curl -O http://ios-driver-ci.ebaystratus.com/userContent/ios-server-standalone-0.6.6-SNAPSHOT.jar
Version info:
$ java version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
$ node -v
v0.10.26
Why does this error happen and how do I fix it?
I managed to solve this by making the spawned child ignore stdin:
var selenium = spawn('java', ['-jar', './ios-server-standalone-0.6.6-SNAPSHOT.jar', '-port', '4444'], {stdio: ['ignore', null, null]});
I'm not sure why this workaround works.
I don't have much idea about it, what so far I've found is that this can be binding issue with java. More details is on following link:(It is not the updated information, it may lead to answer)
http://diario.beerensalat.info/2008/10/12/java_and_ipv6_on_bsd.html
If that is not the case, as this post suggests to change it to higher port should work.
"Protocol family unavailable" error while using VisualVM
Related
`
//soldity is synchronous lang
const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
//http://127.0.0.1:7545
const provider = new ethers.providers.JsonRpcProvider(
"http://127.0.0.1:7545"
);
const wallet = new ethers.Wallet(
"5248c9dfa1d4fb6369c105999f1362867d6acd5cf1dee7ef949870231520fa4f",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait...");
const contract = await contractFactory.deploy(); //stop here and wait for the contract to deploy
console.log(contract);
}
main()
.then(() => ProcessingInstruction.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
`
The error is -
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
at Logger.makeError (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/#ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/#ethersproject/logger/lib/index.js:247:20)
So, I am working with JavaScript and solidity and developing a contract. While deploying the contract on a ganache network using node (all code in VS), I am experiencing this network error. PLeasee help! I am trying to learn and have been trying to solve this. Below is the code.
I had the same problem using WSL subsystem (don't know if it's your case) because my ganache was running on windows while VScode was running on WSL.
I solved the problem using the terminal to installe ganache on WSL:
npm install -g ganache
Then run ganache:
ganache
It will give you some Private Keys, use one of them for your code, and then it show the IP that you have to use in your code:
RPC Listening on 127.0.0.1:3456 //or something similar
Keep ganache running in this terminal and open another one to run "node deploy.js"
Because Ganache is not connected to the WSL enviroment. So, go to the setting of the Ganache and choose the WSL as the server HOSTNAME.Finally, change the RPC in your code. Then it will be done.
let provider = new ethers.providers.JsonRpcProvider(
"HTTP://172.20.80.1:7545"
);
You might be running this from a WSL terminal, I tried running node deploy.js through windows PowerShell or Command prompt and it worked.
Open Your files in vs code without WSL enviornment and then run in terminal it will work because we have installed ganache in windows not in linux
I am trying to learn to use appium, and running their tutorial test code:
const wdio = require('webdriverio');
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
platformVersion: "8.0",
deviceName: "Android Emulator",
app: "C:\Users\SStaple\AppData\Local\Android\Sdk/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
client
.init()
.click("~App")
.click("~Alert Dialogs")
.back()
.back()
.end();
All I get from running this code is Syntax error in Line:1 Char:1.
I thought const was legal Javascript.
What is going on here?
I am running the code from the Command prompt. I hacve installed the Webdriver in the same folder as the Javascript file.
Your JS file is not a Windows executable, nor is it a script that the Windows command prompt can interpret.
You need to run it using a JavaScript runtime. The most popular one is Node.js.
node appiumTest.js
I am trying to learn Appium, using the instructions given in the documentation:
http://appium.io/docs/en/about-appium/getting-started/?lang=en
I have put this code into a file called AppiumTest.js
const wdio = require('webdriverio');
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
platformVersion: "8.0",
deviceName: "Pixel_API_26",
app: "C:/Users/SStaple/AppData/Local/Android/Sdk/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
client
.init()
.click("~App")
.click("~Alert Dialogs")
.back()
.back()
.end();
I am running it from the Node.js command prompt, using the command: node AppiumTest.js, after starting the Appium Server. It was also necessary to have an Android 8 emulator running.
(Appium Server v1.7.1)
I am getting an output in the Appium Server window. There are a number of errors. The first error shown is this:
Error "Command 'C\:\\Users\\SStaple\\AppData\\Local\\Android\\Sdk\\build-tools\\26.0.2\\aapt.exe d badging C\:\\Users\\SStaple\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-driver\\uiautomator2\\appium-uiautomator2-server-v0.1.8.apk' exited with code 1" while getting badging info
I have tried running this command on its own in the Command Prompt:
C:\Users\SStaple\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe d badging C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk
The result I get here is this:
W/zipro (13656): Error opening archive C:\Users\SStaple\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomator2-server-v0.1.8.apk: Invalid file
ERROR: dump failed because no AndroidManifest.xml found
Any ideas?
Update 28/12/2017 - I found the solution!
The file in question looked suspect. It was 0Kb in size!
I downloaded the apk file from https://github.com/appium/appium-uiautomator2-server/releases and used that instead.
This one is 1,518 KB in size.
(Apparently there is some problem with npm not putting that apk file into the right place while beta is installed.)
Having fixed that, I can move on to the next problem!
Its a known issue with apk signing.
You can start with trying to update dependencies:
npm install appium-uiautomator2-driver
npm install appium-adb
If it didn't help, there is more you can try (but that was for Linux):
modify
./node-v6.11.4-linux-armv7l/lib/node_modules/appium/node_modules/appium-adb/build/lib/tools/apk-signing.js so it would return a true even if it looks not signed.
case 20:
context$1$0.prev = 20;
context$1$0.t0 = context$1$0’catch’;
_loggerJs2[‘default’].debug(“App not signed with debug cert.”);
return context$1$0.abrupt(‘return’, true);
I am in the process of debugging a memory leak in our node application. I am however unable to use llnode to show any javascript objects. I've followed Brendan instructions.
I have tested on different versions of Ubuntu 16.04 and 17.04, as well as using node 7 and 8.
I went back and tried a simple case:
var http = require('http');
var host = "127.0.0.1"
var port = 1338
server = http.createServer(function myRequestListener(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
res.not_a_function()
}).listen(port, host);
console.log(`Server process ${process.pid} running at http://${host}:${port}/`);
I then would send a seg fault signal (the above code is put into server.js):
kill -s SIGSEGV `ps -ax | grep server.js | cut -d " " -f 1 | head -n 1`
I then would run:
lldb-4.0 -c /cores/core.dump -f /usr/bin/node
Inside llnode when I queried for javascript objects I got back and empty list.
(lldb) v8 bt
* thread #1: tid = 28763, 0x00007f8947ff7929, name = 'node', stop reason = signal SIGSEGV
* frame #0: 0x00007f8947ff7929
frame #1: 0x00005585e8df035b node`v8_inspector::V8FunctionCall::callWithoutExceptionHandling() + 11
frame #2: 0x00005585e8ddf26c node`v8_inspector::V8Debugger::captureStackTrace(bool) + 92
frame #3: 0x00005585e8bc1493 node`node::inspector::InspectorSocketServer::SocketConnectedCallback(uv_stream_s*, int) + 163
frame #4: 0x00005585e8bbb821 node`node::inspector::InspectorConsoleCall(v8::FunctionCallbackInfo<v8::Value> const&) + 817
frame #5: 0x00007f8947f153f1
(lldb) v8 findjsobjects
Instances Total Size Name
---------- ---------- ----
(lldb)
Where I would expect to find javascript objects. I suspect it is a PEBKAC problem, but if anyone has any pointers to where I might have gone astray.
This is some kind of necroposting, but we had same problem with electron build - v8 findjsobjects returns no output.
All things below for MacOS builds.
So, the problem is in 'visibility' linker flag, which is forced to be 'hidden' in electron builds. That's why v8dbg_ constants, needed for llnode, not attached by linker even with debug ninja config, and llonde can't find any objects.
To beat this we forced default visibility with pragma in python-generated debug-output.cc file and finally was able to view js objects. to follow this path append
#pragma GCC visibility push(default)
before footer declaration in file electron-gn/src/v8/tools/gen-postmortem-metadata.py and rebuild all electron from scratch. Also build can be really huge, make sure you have ~100GB of free space.
I think same thing will works for node/v8 builds alongside electron.
Hope this helps.
I am trying to setup environment for headless testing using Selenium and PhantomJS.
Setting UP phantomjs:
I have made a folder c:/phantomjs and put all the phantomjs script files there (after downloading).
Then I created a folder C:\xampp\htdocs\testPhantomJS
Now I installed nodeJS in my system.
Then I traversed to the C:\xampp\htdocs\testPhantomJS in the command prompt and installed phantomJS like this:
C:\xampp\htdocs\testPhantomJS>npm install -g phantomjs
The image states a different location. Thats because it was taken from my colleague's computer. We both are working on same installation, and he sent me the image for reference. That's why its different with my folder location, but the location I stated, it is the one I worked on.
Now on typing phantomjs on command prompt, when we are typing
C:\xampp\htdocs\testPhantomJS>phantomjs
phantom>
Setting Up Selenium-Webdriver
I traversed to C:\xampp\htdocs\testPhantomJS in the command prompt and installed selenium webdriver like this:
C:\xampp\htdocs\testPhantomJS>npm install selenium-webdriver
After installation, the folder structure is like this:
Now I have a test-script test.js which is like this:
describe('Test example.com', function(){
before(function(done) {
client.init().url('http://google.com', done);
});
describe('Check homepage', function(){
it('should see the correct title', function(done) {
client.getTitle(function(err, title){
expect(title).to.have.string('Example Domain');
done();
});
});
it('should see the body', function(done) {
client.getText('p', function(err, p){
expect(p).to.have.string(
'for illustrative examples in documents.'
);
done();
})
});
});
after(function(done) {
client.end();
done();
});
});
The problem is, where should I put the above script, and how shall I run it?
I just don't need to run using the phantomjs only, I need to test with both phantomjs and selenium.
This solution is coming from this pretty neat tutorial on how to setup testing with selenium and phantomjs: http://code.tutsplus.com/tutorials/headless-functional-testing-with-selenium-and-phantomjs--net-30545
Here is some of the tutorial below:
Combining Everything
Now that we have all the pieces, we have to put everything together.
Remember: before running any tests, you have to run Selenium Server:
1
java -jar selenium-server-standalone-2.28.0.jar
Selenium will run PhantomJS internally; you don't have to worry about that.
Now, we need to connect to Selenium from our JavaScript. Here's a sample snippet, which will initiate a connection to Selenium and have a ready object to control our Selenium instance:
// Use webdriverjs to create a Selenium Client
var client = require('webdriverjs').remote({
desiredCapabilities: {
// You may choose other browsers
// http://code.google.com/p/selenium/wiki/DesiredCapabilities
browserName: 'phantomjs'
},
// webdriverjs has a lot of output which is generally useless
// However, if anything goes wrong, remove this to see more details
logLevel: 'silent'
});
client.init();
Now, we can describe our tests and use the client variable to control the browser.
A full reference for the webdriverjs API is available in the documentation, but here's a short example:
client.url('http://example.com/')
client.getTitle(function(title){
console.log('Title is', title);
});
client.setValue('#field', 'value');
client.submitForm();
client.end();
Let's use the Mocha and Chai syntax to describe a test; we'll test some properties of the example.com web page:
describe('Test example.com', function(){
before(function(done) {
client.init().url('http://example.com', done);
});
describe('Check homepage', function(){
it('should see the correct title', function(done) {
client.getTitle(function(title){
expect(title).to.have.string('Example Domain');
done();
});
});
it('should see the body', function(done) {
client.getText('p', function(p){
expect(title).to.have.string(
'for illustrative examples in documents.'
);
done();
})
});
});
after(function(done) {
client.end();
done();
});
});
You might want to share one client initialization over many test files. Create a small Node module to initialize and import it into every test file:
client.js:
exports.client = require('webdriverjs').remote({
// Settings
};
test.js:
var client = require('./client').client;
var expect = require('chai').expect;
// Perform tests
EDIT based on the question in the comments:
Here is how to install the selenium server, and yes you need to do it.
Selenium
Download Selenium Server. It is distributed as a single jar file, which you run simply:
java -jar selenium-server-standalone-2.28.0.jar
As soon as you execute this command, it boots up a server to which your testing code will connect later on. Please note that you will need to run Selenium Server every time that you run your tests.