SSHException: Channel closed - python

I am using following code connect the RC (windows server) server via SSH library. when I am trying to execute command,
*** Settings ***
Library OperatingSystem
Library SSHLibrary
*** Test Cases ***
Test
SSHLibrary.Open Connection 10.117.207.225 alias=ssh \
SSHLibrary.Login reutadmin Reuters01 delay=1s
${stdout} ${stderr}= Execute Command echo 'Hello John!' return_stderr=True
Should Be Empty ${stderr}
log ${stderr}
Getting the following Error. Can you please help me on this case:
enter image description here channel connection closed:enter image description here

I had similar situation, in my case the error happened during Login step.
The cause was PermitTTY no in sshd server configuration. It was setup to serve only SFTP, and without TTY robotframework failed to login.
Changed server configuration to PermitTTY yes (which is default) resolved the issue.

Related

APPIUM: Cannot bind listener: cannot bind to 127.0.0.1:8200

Suddenly I’m Facing this error when I try to run appium.
Error:
An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:\Users\vsingh\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790’ exited with code 1’; Stderr: ‘adb.exe: error: cannot bind listener: cannot bind to 127.0.0.1:8200: An attempt was made to access a socket in a way forbidden by its access permissions. (10013)’; Code: ‘1’
desired Cap:
{
“deviceName”: “myphone”,
“udid”: “emulator-5554”,
“platformName”: “Android”,
“platformVersion”: “9.0”,
“appWaitActivity”: “com.application.activity.MainDrawerActivity”,
“appWaitPackage”: “com.application.pas”,
“noReset”: true
}
Tried adb kill-server, adb root. but still no effect.
It was working fine till yesterday.
Using Appium Inspector
Most likely port is left in-use.
Try running sudo lsof -i | grep 8080 or nc -l 0.0.0.0 8080 on machine terminal, whatever works to see if port in use.
If it is in use, then stop the process. The best way to avoid it in future is either create cleanup scripts to free all required ports before you start tests again or run tests in docker container.

Yocto Project Bitbake Unexpected Termination

I just got my i.MX 8M Evaluation Kit and I followed the tutorial to make the system for my board.
I build the system on a host machine with Ubuntu 16.04 and I followed all instructions in Section-3 to set up my host machine.
I'm trying to build the Wayland image with OPTEE enabled so the commands are:
$ DISTRO=fsl-imx-wayland MACHINE=imx8mqevk source fsl-setup-release.sh -b build-wayland
Comment two SDL settings in local.conf: PACKAGECONFIG_append_pn-qemu-native = " sdl", PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
Enable OPTEE in local.conf
$ bitbake fsl-image-qt5-validation-imx
The issue happens after the "bitbake" command, which is the script would suddenly be stopped and the host machine would be suspended and required re-login. The bitbake command can be continued with "-k" parameter while the unknown termination and re-login process are really annoying to me.
By reviewing the bitbake log file bitbake-cookerdeamon.log, I found that every time before unexpected termination, the bitbake command generates the same logs:
Accepting [<socket.socket fd=7, family=AddressFamily.AF_UNIX,
type=SocketKind.SOCK_STREAM, proto=0, laddr=bitbake.sock>] Connecting
Running command ['updateConfig', ...]
Running command ['getVariable', 'BBINCLUDELOGS']
Running command ['getVariable', 'BBINCLUDELOGS_LINES']
Running command ['getSetVariable', 'BB_CONSOLELOG']
Running command ['getUIHandlerNum']
Running command ['setEventMask', ...]
Running command ['getVariable', 'BB_DEFAULT_TASK']
Running command ['setConfig', 'cmd', 'build']
Running command ['buildTargets', ['fsl-image-qt5-validation-imx'], 'build']
Running command ['stateForceShutdown']
Connecting Client
Disconnecting Client
No timeout, exiting.
Exiting
According to my current understanding, the above commands are only supposed to be executed after all tasks have been prepared. However, right now my host machine may invoke these commands during other tasks are still running, and this incorrect sequence leads to my unexpected termination issue.
I'm wondering if anyone runs to a similar problem or knows the solution to my issue?
Any suggestion is welcomed. Thank you in advance.
Simon
-----Supplemental Information
Here is the content of the configuration file fsl-imx-wayland.conf
# i.MX DISTRO for Wayland without X11
include conf/distro/include/fsl-imx-base.inc include
conf/distro/include/fsl-imx-preferred-env.inc
DISTRO = "fsl-imx-wayland"
# Remove conflicting backends DISTRO_FEATURES_remove = "directfb x11 " DISTRO_FEATURES_append = " wayland pam systemd"

syslog measurement not appearing in influxdb

TL;DR Not able to see syslog logs in influxdb
Environment:
OS: mac os mojave
telegraf version: 1.8
influxdb version: 1.6.4
So I wanted to view logs in chronograf and figured out from the set of input plugins offered in telegraf to use the syslog plugin.
I have followed the instructions here, but have added the steps here too for easy read.
I installed rsyslog via homebrew as follows:
$ brew install rsyslog
Added the following in /usr/local/etc/rsyslog.conf:
$WorkDirectory /tmp/rsyslog # temporary directory for storing data
$ActionQueueType LinkedList # use asynchronous processing
$ActionQueueFileName srvrfwd # set file name, also enables disk mode
$ActionResumeRetryCount -1 # infinite retries on insert failure
$ActionQueueSaveOnShutdown on # save in-memory data if rsyslog shuts down
$ModLoad imudp #loads the udp module
#listen for messages on udp localhost:514
$UDPServerAddress localhost
$UDPServerRun 514
*.* ##(o)127.0.0.1:6514;RSYSLOG_SyslogProtocol23Format
restarted rsyslog:
$ sudo brew services restart rsyslog
I configured telegraf as follows:
# # Accepts syslog messages per RFC5425
[[inputs.syslog]]
# ## Specify an ip or hostname with port - eg., tcp://localhost:6514, tcp://10.0.0.1:6514
# ## Protocol, address and port to host the syslog receiver.
# ## If no host is specified, then localhost is used.
# ## If no port is specified, 6514 is used (RFC5425#section-4.1).
server = "tcp://localhost:6514"
and restarted telegraf as follows:
$ brew services restart telegraf
But my expectation was to see syslog measurement inside of telegrafdatabase
I wrote the following python script to log to syslog hoping that it would appear in the database:
import logging
import logging.handlers
my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)
handler = logging.handlers.SysLogHandler(address='/var/run/syslog')
my_logger.addHandler(handler)
my_logger.debug('this is debug')
my_logger.critical('this is critical')
but to no avail.
What could be wrong here? If so is there a log file I could check in?
EDIT 1:
So I troubleshooted rsyslog using the rsyslogd -N1 command and found some issues:
The configuration file must be in /etc/rsyslog.conf.
The configuration file working directory i.e; /tmp/rsyslog wasn't found so created one.
There were some errors in rsyslog.conf file (can be seen in edits of this question)
After doing all the above I restarted rsyslog and also influxdb and telegraf and checked again if there were any errors by running the rsyslogd -N1 command and the following is the output:
rsyslogd: version 8.37.0, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: End of config validation run. Bye.
Still the same issue persists.
EDIT 2:
related post: syslog-plugin-from-remote-server

mongodb refusing connection in python

I am using windows8, for writing code I use IDLE. I tried to connect python to mongodb. But when trying to get collection name than it gives an error.
ServerSelectionTimeoutError: localhost:20101: [Errno 10061] No connection could be made because the target machine actively refused it
This is code for which i am getting an error.
from pymongo import MongoClient
connection = MongoClient('localhost',20101)
db = connection['Bhautik']
collection = db['Student']
db.collection_names(include_system_collections=True)
By the output message you probably didn't set your mongo bind_ip or didn't set the dbpath. Try this:
mongod --dbpath <database_path> --bind_ip 127.0.0.1 --port 20101
It would be more helpful to put alongside with your code some information regarding the mongodb configuration, like the server port, if you are using authentication or not, which dbpath you are using and so on.
So put in your question your mongodb.conf (if you are using one) or the command you are using to start the mongo server.
If you are starting to use mongoDB after installation, make C:/data/db because it is a default database directory which mongoDB uses.
To change the database directory, do type below:
C:\Program Files\MongoDB\Server\3.x\bin> mongod --dbpath "c:\custom_folder"
You can try
run mongo like that:
"C:\\Program Files\\MongoDB\\Server\\3.6\\bin\\mongod.exe" --dbpath E:\\data\\db --port 27017 --bind_ip 127.0.0.1
E:\data\db should be your location path
then in you code
it will lok like
client = MongoClient("127.0.0.1", 27017)
db = client['addsome']
datas = db.follow_up
and if you want to access from a distant machine make sure you open the port "27017" in the firewall
Some times it's gives this error when you forgot to run the local server (if it's run with local server).
To run it you need to write on your terminal:
mongod
or, if MongoDB not in PATH, you can find it via this link in your computer:
C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe
In order to run MongoDB,
You should have installed MongoDB into your OS, download it from https://www.mongodb.com/download-center/community?tck=docs_server
Add the installation's bin folder to your system environment variables.
Openup the terminal and check 'mongod' and 'mongo' commands are working.
Then try to rerun your python script.

Why am I receiving a low level socket error when using the Fabric python library?

When I run the command:
fab -H localhost host_type
I receive the following error:
[localhost] Executing task 'host_type'
[localhost] run: uname -s
Fatal error: Low level socket error connecting to host localhost: Connection refused
Aborting.
Any thoughts as to why? Thanks.
Fabfile.py
from fabric.api import run
def host_type():
run('uname -s')
Configuration
Fabric 1.0a0 (installed from the most recent Github commit---b8e1b6a)
Paramiko 1.7.4
PyCrypto 2.0.1
Virtualenv ver 1.3.3
Python 2.6.2+ (release26-maint:74924, Sep 18 2009, 16:03:18)
Mac OS X 10.6.1
The important part isn't the "low level error" part of the message - the important part is the "Connection refused" part. You'll get a "connection refused" message when trying to connect to a closed port.
The most likely scenario is that you are not running an ssh server on your machine at the time that Fabric is running. If you do
ssh localhost
you'll probably get a message similar to
ssh: connect to host localhost: Connection refused
So you'll have to go out and set up an SSH server on your computer before you can proceed with Fabric from there.
I had the same problem, but the reason was different: While I could easily log in to the server via SSH (default port 22), fabric tried to connect on a closed port 9090.
Finally I recognized that I had defined "env.port=9090" in my old fabfile for some WSGI server setup; while that was never a problem, I updated my Python installation some weeks before, and fabric now uses env.port for its SSH connection.
I just renamed that config, and all is well again.
This can also happen in OS X 10.11.4 and Fabric 1.10.1, in the case where you are ssh'ing to a VM using Vagrant, which does port forwarding from localhost. In this case, localhost was resolving to the IPv6 ::1 address (not due to /etc/hosts file), and giving this error.
The fix was to force use of IPv4 by using the 127.0.0.1 address in the fabfile instead of the hostname. Using a hostname in /etc/hosts with this address didn't work.
You might also want to try these useful tips for debugging connection issues in Fabric.
env.roledefs = {
'role1': env.hosts[0:5],
'role2':[env.hosts[5],]
}
I encountered the same error if "role" value IS NOT A LIST. for example, the above code works but the following doesn't.
env.roledefs = {
'role1': env.hosts[0:5],
'role2':env.hosts[5],
}

Categories