PulseAudioService pa_context_connect() failed in all Qt GUI applications - qt

I have an embedded linux device that is running linux kernel 4.4 and QT5.9.1 with busybox. I have two applications written in QT, one with a GUI and another backend service also written in QT but has no GUI or widgets whatsoever, console only. I've recently been trying to pair and connect bluetooth audio devices to record and playback audio using pulseaudio and bluez. I also have a camera that records live video displayed on the GUI while recording audio from the bluetooth headset. This is done using gstreamer in the wirelesscontroller service.
This all works fine, but when going to play back saved videos with the audio I use the Video widget in the GUI to simplify things. Unfortunately it doesnt recognize the default audio device from pulseaudio as being the bluetooth headset/speaker and instead always forces it out of the 3.5mm audio jack. I tried using this code to print out the list of available audio devices as well as what QT thinks is the default audio device:
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo &deviceInfo : deviceInfos)
qDebug() << "Device name: " << deviceInfo.deviceName();
qWarning() << "default device: " << QAudioDeviceInfo::defaultOutputDevice().deviceName();
I originally tried this in the backend wirelesscontroller service and it prints this:
[M] qWirelessController WirelessControllerMain::init - Device name: "default"
[M] qWirelessController WirelessControllerMain::init - Device name: "default:CARD=rockchipwitorch"
[M] qWirelessController WirelessControllerMain::init - Device name: "sysdefault:CARD=rockchipwitorch"
[M] qWirelessController WirelessControllerMain::init - Device name: "bluez_sink.0C_A6_94_E4_22_B9.headset_head_unit"
[M] qWirelessController WirelessControllerMain::init - Device name: "alsa_output.0.stereo-fallback"
[W] qWirelessController WirelessControllerMain::init - default device: "bluez_sink.0C_A6_94_E4_22_B9.headset_head_unit"
So the backend service has no problem recognizing the default audio device. I tried adding this same code snippet to my GUI application and I get this error message:
[W] MyGUI - PulseAudioService: pa_context_connect() failed with return: -1
[M] MyGUI HMIMain::init - Device name: "default"
[M] MyGUI HMIMain::init - Device name: "default:CARD=rockchipwitorch"
[M] MyGUI HMIMain::init - Device name: "sysdefault:CARD=rockchipwitorch"
[M] MyGUI HMIMain::init - Device name: ""
[W] MyGUI HMIMain::init - default device: ""
It errors out trying to connect to the pulseaudio service. Ive searched a lot on this error and so far nothing ive found is either relevant to my setup or has fixed my issue. Ive also found that this error occurs on ALL GUI applications. I built a number of QT examples with and without GUIs and put that code snippet in them. All of the GUI applications give me the same pa_context_connect() error whereas all of the console based applications have no problem connecting with the pulse audio service.
From what I can tell, it does not matter how many QT console applications are running, they all are able to connect to the pulseaudio service. I've also made sure that no other user applications are running when trying to get my GUI application to connect with pulseaudio. Currently I'm starting pulseaudio with these parameters:
/usr/bin/pulseaudio -D --exit-idle-time=-1
I have tried launching it with the --system parameter as well as setting the environment variable PULSE_SERVER=localhost and both of those result in me getting the following error:
"PulseAudioService: Connection failure: Connection refused"
If I run pulseaudio in the background (not as a daemon) and --vvvv I see it print out a lot of information when my backend service connects to it but naturally, I see absolutely nothing when my GUI application attempts to connect to it.
I have also tried removing all my pulseaudio cookies in the .config/pulse/ folder as one thread suggested but that also didnt change anything.
As far as the configuration files in /etc/pulse/ I have reverted them all to stock. However, the only change I've had to make was adding "load-module module-stream-restore restore_device=false" to default.pa to get the default sink to maintain.
I really dont want to add more gstreamer code to play back videos so I would really like to figure out what is going on here.
EDIT: i recently found the environment variable "QT_DEBUG_PLUGINS" and launched my application with it set to one and got this output:
[M] MyGUI - QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/qt/plugins/audio" ...
[M] MyGUI - QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/audio/libqtaudio_alsa.so"
[W] MyGUI - Found metadata in lib /usr/lib/qt/plugins/audio/libqtaudio_alsa.so, metadata=
{
"IID": "org.qt-project.qt.audiosystemfactory/5.0",
"MetaData": {
"Keys": [
"alsa"
]
},
"className": "QAlsaPlugin",
"debug": false,
"version": 329988
}
[M] MyGUI - Got keys from plugin meta data ("alsa")
[M] MyGUI - QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt/plugins/audio/libqtmedia_pulse.so"
[W] MyGUI - Found metadata in lib /usr/lib/qt/plugins/audio/libqtmedia_pulse.so, metadata=
{
"IID": "org.qt-project.qt.audiosystemfactory/5.0",
"MetaData": {
"Keys": [
"default"
]
},
"className": "QPulseAudioPlugin",
"debug": false,
"version": 329988
}
[M] MyGUI - Got keys from plugin meta data ("default")
[M] MyGUI - QFactoryLoader::QFactoryLoader() checking directory path "/mnt/app/bin/audio" ...
[M] MyGUI - loaded library "/usr/lib/qt/plugins/audio/libqtaudio_alsa.so"
[M] MyGUI - loaded library "/usr/lib/qt/plugins/audio/libqtmedia_pulse.so"
[W] MyGUI - PulseAudioService: pa_context_connect() failed with return: -1
[M] MyGUI HMIMain::init - Device name: "default"
[M] MyGUI HMIMain::init - Device name: "default:CARD=rockchipwitorch"
[M] MyGUI HMIMain::init - Device name: "sysdefault:CARD=rockchipwitorch"
[M] MyGUI HMIMain::init - Device name: ""
[W] MyGUI HMIMain::init - default device: ""

all credit to KH-219Design on the qt forums for his help on this.
using the environment variable PULSE_LOG=4 I was able to diagnose that the GUI was using the XDG_RUNTIME_DIR to look for the pulse server socket. The XDG environment variable was being used for it to work with wayland which the console application didnt need.
the pulse server socket was located in /tmp/pulse-/native and the GUI was not able to find it to connect to it because it was looking in /tmp/.xdg/pulse/native

Related

Which driver I need to use PeakCan in Qt6?

I need to use Peak System PCAN USB dongle in my Qt6 application.
At first I checked it works from command line.
In my Ubuntu 20.04 I have the kernel drivers installed:
$ grep PEAK_ /boot/config-`uname -r`
CONFIG_CAN_PEAK_PCIEFD=m
CONFIG_CAN_PEAK_PCI=m
CONFIG_CAN_PEAK_PCIEC=y
CONFIG_CAN_PEAK_PCMCIA=m
CONFIG_CAN_PEAK_USB=m
and loaded:
$ lsmod | grep ^peak
peak_usb 49152 0
I also tried to exchange data with can-tools and it worked out of the box.
Here the relevant output of the ip command:
$ ip addr
6: can0: <NOARP,ECHO> mtu 16 qdisc pfifo_fast state DOWN group default qlen 10
link/can
The problem arises when I try to connect from the Qt application:
std::unique_ptr<QCanBusDevice> _device;
QString errorString;
_device.reset(QCanBus::instance()->createDevice("peakcan", "can0", &errorString));
I get:
qt.canbus.plugins.peakcan: Cannot load library pcanbasic: (pcanbasic: cannot open shared object file: No such file or directory)
So I downloaded the PCAN Basic package.
In the readme there are the requirements:
System Requirements
-------------------
- PCAN Linux Driver: 8.0.17 and above
(Driver for Linux can be download at www.peak-system.com/linux)
So I compiled and installed the drivers. Now the peakcan plugin is found:
qt.canbus.plugins.peakcan: Using PCAN-API version: 4.5.2.15
but now:
no device is discovered by Qt
ip addr shows no can devices
lsmod | grep ^peak shows no drivers loaded
Question #1: am I missing anything in order to get it works?
By the way, in the Linux driver page they also state:
The CAN interfaces are then accessed via the common SocketCAN framework as network devices
Hence I tried to find any available device using socketcan:
QString errorString;
const QList<QCanBusDeviceInfo> devices = QCanBus::instance()->availableDevices(QStringLiteral("socketcan"), &errorString);
if (!errorString.isEmpty()) qDebug() << errorString;
foreach (QCanBusDeviceInfo info, devices)
{
qDebug() << info.name();
}
but it finds no devices.
If I try to connect to it:
std::unique_ptr<QCanBusDevice> _device;
QString errorString;
_device.reset(QCanBus::instance()->createDevice("socketcan", "can0", &errorString));
I get:
RTNETLINK answers: Operation not permitted
I guess because I'm running the application with user privileges.
I get the same error if I try to bring the interface up without sudo:
$ ip link set can0 up
RTNETLINK answers: Operation not permitted
Question #2: Is there any group I need to join to in order to let Qt6 to bring up the network device without root privileges?

EUCA 4.4.5 VPCMIDO Instances Terminate at Launch

I have achieved a small test cloud on 3 pieces of hardware. It works fine when in EDGE mode but when I try to configure it for VPCMIDO, new instances begin to launch but then timeout and move to a terminated state. I can also see the instances' initial volume and config data appear in the NC and CC data directories. Below is my system layout and network.json.
HOST 1 : CLC/UFS/WALRUS/MIDO CLUSTER/MIDO GATEWAY/MIDOLMAN AGENT:
em1 (All Services including Mido Cluster): 10.0.0.21
em3 (Target VPCMIDO Adapter): 10.0.0.22
HOST 2 : CC/SC
em1 : 10.0.0.23
HOST 3 : NC/MIDOLMAN AGENT
em1 : 10.0.0.24
{
"Mido": {
"Gateways": [
{
"Ip": "10.0.0.22",
"ExternalDevice": "em3",
"ExternalCidr": "192.168.0.0/16",
"ExternalIp": "192.168.0.2",
"ExternalRouterIp": "192.168.0.1"
}
]
},
"Mode": "VPCMIDO",
"PublicIps": [
"10.0.100.1-10.0.100.254"
]
}
I may be misunderstanding the intent of reserving an interface just for the mido gateway. All of my eucalyptus/zookeeper/cassandra/midonet configs use the 10.0.0.21 interface and seem to communicate fine. The midonet tunnel zone reports my CLC host and NC host successfully in the tunnel zone. The only part of my config that references the interface I intend to use for the midonet gateway is the network.json. No errors were returned at any time during my config so I think I may be missing something conceptual.
You may need to start eucanetd as described here:
https://docs.eucalyptus.cloud/eucalyptus/4.4.5/index.html#install-guide/starting_euca_clc.html
The eucanetd component in vpcmido mode runs on the cloud controller and is responsible for controlling midonet.
When eucanetd is not running instances will fail to start as the required network resources will not be created.
I configured a bridge on the NC and instances were able to launch and I no longer got an error in my nc.log. Docs and the eucalyptus.conf file comments tell me I shouldn't need to do this in VPCMIDO netowrking mode: https://docs.eucalyptus.cloud/eucalyptus/4.4.5/index.html#install-guide/configuring_bridge.html
Despite all that adding the bridge fixed this issue.

Appium recorded code not working when launched via nodes

I have successfully installed and run appium desktop. I took to recording my test. The recorder's output code was as follows:
// Requires the webdriverio client library
// (npm install webdriverio)
// Then paste this into a .js file and run with Node:
// node <file>.js
const wdio = require('webdriverio');
const caps = {"platformName":"android","platformVersion":"8.0","deviceName":"Nexus_6_API_26_2","automationName":"UiAutomator2","app":"path/to/my/apk"};
const driver = wdio.remote({
protocol: "http",
host: "127.0.0.1",
port: 4723,
path: "/wd/hub",
desiredCapabilities: caps
});
driver.init()
.element("/some/xpath")
.setValue("Hello World!")
.end();
However this setup after running with node this_test.js will find error
Error: Required option "capabilities" is missing
Therefore I changed desiredCapabilities: caps to capabilities: caps, but after that I get error
TypeError: driver.init is not a function
What can I change to fix this? I have tried reinstalling webdriverio with both npm install -g webdriverio and yarn add webdriverio.
My server is running on 127.0.0.1:4723 with message "The URL '/' did not map to a valid resource" (if that is relevant)
Are you using MAC or Windows machine ? The address for MAC would be different, something like 0.0.0.0:4723/wd/hub

Why does Meteor Up (MUP) fail on authentication?

I am currently trying to deploy a Meteor project to an external server for the first time. The server is hosted by DigitalOcean, running ubuntu 16.04, and has an SSH key set up for password-free access.
The error I am getting from MUP is:
[159.203.165.13] - Setup Docker
events.js:165
throw er; // Unhandled 'error' event
^
Error: All configured authentication methods failed
at tryNextAuth (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/ssh2/lib/client.js:290:17)
at SSH2Stream.onUSERAUTH_FAILURE (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/ssh2/lib/client.js:469:5)
at SSH2Stream.emit (events.js:180:13)
at parsePacket (/usr/lib/node_modules/mup/node_modules/ssh2-streams/lib/ssh.js:3647:10)
at SSH2Stream._transform (/usr/lib/node_modules/mup/node_modules/ssh2-streams/lib/ssh.js:551:13)
at SSH2Stream.Transform._read (_stream_transform.js:185:10)
at SSH2Stream._read (/usr/lib/node_modules/mup/node_modules/ssh2-streams/lib/ssh.js:212:15)
at SSH2Stream.Transform._write (_stream_transform.js:173:12)
at doWrite (_stream_writable.js:410:12)
at writeOrBuffer (_stream_writable.js:396:5)
at SSH2Stream.Writable.write (_stream_writable.js:294:11)
at Socket.ondata (_stream_readable.js:651:20)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at Socket.Readable.push (_stream_readable.js:218:10)
Emitted 'error' event at:
at tryNextAuth (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/ssh2/lib/client.js:292:12)
at SSH2Stream.onUSERAUTH_FAILURE (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/ssh2/lib/client.js:469:5)
[... lines matching original stack trace ...]
at Socket.Readable.push (_stream_readable.js:218:10)
At this point I have tried several solutions involving the mup file as per other recommendations such as:
1) Adding in a password - Gives the exact same error as though the change didn't occur.
2) Adding in the same SSH key that I use for authentication to the server as per digital ocean - Says 'privateKey value does not contain a (valid) private key'. I have tried both the key that is used for authentication to the server and every other key I could find short of generating a new one just for Meteor's use.
3) Leaving both blank and allowing it to 'try' ssh-agent - pretends it doesn't know what ssh-agent is and throws an error saying the same thing as when I use a password.
I have looked through and followed the same instructions in the following article: http://meteortips.com/deployment-tutorial/digitalocean-part-1/
This article assumes that there are only two possible states. One being that an ssh key has NOT been used or set up so it needs to be generated. The second being that an ssh key exists and is set up exactly where they expect it. Unfortunately I seem to be in a different situation. I generated a key using putty prior to setting up the D.O server and created the droplet using that. After creation, the file did not exist. The only thing in the ~/.ssh/ directory was a single file named "authorized_keys" that held the key I would use to connect to the server. This file cannot be used, nor any file on the server in the other ssh key locations.I also tried copying over the file directly onto the server to no avail as well.
In some vain hope at finding a solution I also tried running these same commands in both the Meteor build bundle an the source code folder. Neither worked. I should mention that although this is the only article I still have open to try for a solution, I have tried every one I could find using MUP.
If anyone can point me in the right direction with this so I can stop flailing wildly in the dark I would be incredibly grateful.
Edit: As requested, below is the current mup.js file with removed credentials
module.exports = {
servers: {
one: {
// TODO: set host address, username, and authentication method
host: '111.111.111.11',
username: 'root',
// ssh-agent: '/home/Meteor/MeteorKey.pem'
pem: '~/.ssh/id_rsa.pub'
// password: 'password1'
// or neither for authenticate from ssh-agent
}
},
app: {
// TODO: change app name and path
name: 'app-name',
path: '../',
servers: {
one: {},
},
buildOptions: {
serverOnly: true,
},
env: {
// TODO: Change to your app's url
// If you are using ssl, it needs to start with https://
ROOT_URL: 'http://www.app-name.com',
MONGO_URL: 'mongodb://mongodb/meteor',
MONGO_OPLOG_URL: 'mongodb://mongodb/local',
},
docker: {
// change to 'abernix/meteord:base' if your app is using Meteor 1.4 - 1.5
image: 'abernix/meteord:node-8.4.0-base',
},
// Show progress bar while uploading bundle to server
// You might need to disable it on CI servers
enableUploadProgressBar: true
},
mongo: {
version: '3.4.1',
servers: {
one: {}
}
},
// (Optional)
// Use the proxy to setup ssl or to route requests to the correct
// app when there are several apps
// proxy: {
// domains: 'mywebsite.com,www.mywebsite.com',
The error message you are receiving:
Error: All configured authentication methods failed
Means that the SSH connection is failing. So the credentials you are using (pity you removed them from the config) are not working. Try using a command line ssh using these same credentials, and then trouble shoot that - once you can ssh into the server, then mup should be able to do it's work.
You can get more information out of ssh by specifying one or more -v parameters, eg:
ssh -v -v my_user#remote.com
and it will give you information about the authentication methods it is trying as it goes through them. This will help you narrow down the problem.

Mupx deployment with Meteor.js fails when "Installing Docker"

I have Ubuntu 14.04, developing on it and want to have a test server on the same computer. It is ran in Virtual Box.
So I followed all the steps on Github for Mupx setup and watched the video that Meteor.js guide told me to watch it. When I get to command:
mupx setup
it shows me the screen with the error:
nejc#nejc-vb:~/Meteor Projects/CSGO/CSGO-deploy$ mupx setup
Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Configuration file : mup.json
Settings file : settings.json
“ Checkout Kadira!
It's the best way to monitor performance of your app.
Visit: https://kadira.io/mup ”
Started TaskList: Setup (linux)
[my_public_IP] - Installing Docker
events.js:72
throw er; // Unhandled 'error' event
^
Error: Timed out while waiting for handshake
at null._onTimeout (/usr/local/lib/node_modules/mupx/node_modules/nodemiral/node_modules/ssh2/lib/client.js:138:17)
at Timer.listOnTimeout [as ontimeout] (timers.js:121:15)
My mup.json file looks like this:
{
// Server authentication info
"servers": [
{
"host": "my_public_IP",
"username": "nejc",
"password": "123456",
// or pem file (ssh based authentication)
// WARNING: Keys protected by a passphrase are not supported
//"pem": "~/.ssh/id_rsa"
// Also, for non-standard ssh port use this
//"sshOptions": { "port" : 49154 },
// server specific environment variables
"env": {}
}
],
// Install MongoDB on the server. Does not destroy the local MongoDB on future setups
"setupMongo": true,
// Application name (no spaces).
"appName": "CSGO",
// Location of app (local directory). This can reference '~' as the users home directory.
// i.e., "app": "~/Meteor Projects/CSGO",
// This is the same as the line below.
"app": "/home/nejc/Meteor Projects/CSGO",
// Configure environment
// ROOT_URL must be set to your correct domain (https or http)
"env": {
"PORT": 80,
"ROOT_URL": "http://my_public_IP"
},
// Meteor Up checks if the app comes online just after the deployment.
// Before mup checks that, it will wait for the number of seconds configured below.
"deployCheckWaitTime": 30,
// show a progress bar while uploading.
// Make it false when you deploy using a CI box.
"enableUploadProgressBar": true
}

Resources