Storm UI with streamparse - nimbus

I am working on an streamparse project on an AWS instance with ZooKeeper and Nimbus installed. I want to use the Storm UI. I ran sparse submit with the following config.json file:
{
"library": "",
"topology_specs": "topologies/",
"virtualenv_specs": "virtualenvs/" ,
"envs": {
"prod": {
"user": "ubuntu",
"nimbus": "127.0.0.1",
"workers": [
"127.0.0.1"
],
"log": {
"path": "/var/log/storm/streamparse",
"max_bytes": 100000,
"backup_count": 10,
"level": "info"
},
"use_ssh_for_nimbus": false,
"use_virtualenv": false,
"virtualenv_root": ".virtualenvs/storm"
}
}
}
It gives following error trace:
Cleaning from prior builds...
Creating topology Uber-JAR...
Uber-JAR created: /home/ubuntu/airstorm/_build/wordcount-0.0.1-SNAPSHOT-standalone.jar
Deploying "wordcount" topology...
Routing Python logging to /var/log/storm/streamparse.
Running lein command to submit topology to nimbus:
lein run -m streamparse.commands.submit_topology/-main topologies/wordcount.clj --host 127.0.0.1 --port 6627 --option 'topology.workers=2' --option 'topology.acker.executors=2' --option 'streamparse.log.path="/var/log/storm/streamparse"' --option 'streamparse.log.max_bytes=100000' --option 'streamparse.log.backup_count=10' --option 'streamparse.log.level="info"'
{:option {streamparse.log.level info, streamparse.log.backup_count 10, streamparse.log.max_bytes 100000, streamparse.log.path /var/log/storm/streamparse, topology.acker.executors 2, topology.workers 2}, :debug false, :port 6627, :host 127.0.0.1, :help false}
Caught exception: org.apache.thrift7.transport.TTransportException: java.net.ConnectException: Connection refused
java.lang.RuntimeException: org.apache.thrift7.transport.TTransportException: java.net.ConnectException: Connection refused
at backtype.storm.utils.NimbusClient.getConfiguredClient (NimbusClient.java:38)
backtype.storm.StormSubmitter.submitTopology (StormSubmitter.java:116)
backtype.storm.StormSubmitter.submitTopology (StormSubmitter.java:70)
streamparse.commands.submit_topology$submit_topology_BANG_.invoke (submit_topology.clj:23)
streamparse.commands.submit_topology$_main.doInvoke (submit_topology.clj:86)
clojure.lang.RestFn.invoke (RestFn.java:2422)
clojure.lang.Var.invoke (Var.java:496)
user$eval5.invoke (form-init6482794978849376851.clj:1)
clojure.lang.Compiler.eval (Compiler.java:6619)
clojure.lang.Compiler.eval (Compiler.java:6609)
clojure.lang.Compiler.load (Compiler.java:7064)
clojure.lang.Compiler.loadFile (Compiler.java:7020)
clojure.main$load_script.invoke (main.clj:294)
clojure.main$init_opt.invoke (main.clj:299)
clojure.main$initialize.invoke (main.clj:327)
clojure.main$null_opt.invoke (main.clj:362)
clojure.main$main.doInvoke (main.clj:440)
clojure.lang.RestFn.invoke (RestFn.java:421)
clojure.lang.Var.invoke (Var.java:419)
clojure.lang.AFn.applyToHelper (AFn.java:163)
clojure.lang.Var.applyTo (Var.java:532)
clojure.main.main (main.java:37)
Exception in thread "main" java.lang.NullPointerException
at streamparse.commands.submit_topology$submit_topology_BANG_.invoke(submit_topology.clj:28)
at streamparse.commands.submit_topology$_main.doInvoke(submit_topology.clj:86)
at clojure.lang.RestFn.invoke(RestFn.java:2422)
at clojure.lang.Var.invoke(Var.java:496)
at user$eval5.invoke(form-init6482794978849376851.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Traceback (most recent call last):
File "/home/ubuntu/.virtualenvs/storm/bin/sparse", line 11, in <module>
sys.exit(main())
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/streamparse/cli/sparse.py", line 53, in main
args.func(args)
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/streamparse/cli/submit.py", line 242, in main
wait=args.wait, simple_jar=args.simple_jar)
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/streamparse/cli/submit.py", line 204, in submit_topology
host=host, port=port)
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/streamparse/cli/submit.py", line 136, in _submit_topology
run(full_cmd)
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/invoke/runner.py", line 349, in run
return runner.run(command, **kwargs)
File "/home/ubuntu/.virtualenvs/storm/local/lib/python2.7/site-packages/invoke/runner.py", line 153, in run
raise Failure(result)
invoke.exceptions.Failure: Command execution failure!
Exit code: 1
Stderr:
Exception in thread "main" java.lang.NullPointerException
at streamparse.commands.submit_topology$submit_topology_BANG_.invoke(submit_topology.clj:28)
at streamparse.commands.submit_topology$_main.doInvoke(submit_topology.clj:86)
at clojure.lang.RestFn.invoke(RestFn.java:2422)
at clojure.lang.Var.invoke(Var.java:496)
at user$eval5.invoke(form-init6482794978849376851.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$init_opt.invoke(main.clj:299)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)

Related

How to connect to database via asyncssh (Tunnel) and psycop2?

python 3.11 / asyncssh 2.13 / psycopg2-binary 2.9.5
After using the sshtunnel library i wanted to switch to the asyncssh library because its more maintained with newer Python Versions and brings async benefits.
After reading the asyncssh Doc i wrote a little test script and could connect via SSH from my local computer to my Server. I execute some ls terminal statement on my server and could print the outcome with my python script. After that small success i wanted to connect to my postgreSQL Database via the asyncssh Tunnel, so i can push my local panda data to my server database.
In the past it worked well with the sshtunnel library. Unfortunately i fail with asyncssh library to establish a connection to my database on my server.
Problem
My main Problem is to wrap psycopg2 into the tunnel like in sshtunnel with remote_bind_address. I tried with forward_local_port or forward_remote_port and it seems the connection is established but how to funnel psycopg2 into it? Instead of connecting to my 'Server-Database Port 5432' i should connect to the tunnel port (see example 2)?
Example: How sshtunnel worked.
(this is an from geo.rocks but i used that structure also).
import psycopg2
from sshtunnel import SSHTunnelForwarder
try:
with SSHTunnelForwarder(
('some.linktodb.com', 22), # port 22 as standard SSH port
ssh_username="username",
ssh_pkey="your/private/key", # your private key file
ssh_private_key_password="****",
remote_bind_address=('localhost', 5432)) as server: # mirroring to local port 5432
server.start()
params = { # database params
'database': 'test',
'user': 'dome',
'password': '*****',
'host': 'localhost',
'port': server.local_bind_port
}
conn = psycopg2.connect(**params)
curs = conn.cursor() # if this works, you are connected
print("DB connected")
except:
print("Connection failed")
Example: My current asyncssh approach.
async def run_client() -> None:
async with asyncssh.connect(
host=os.environ.get('SSH_HOST'),
known_hosts=None,
username=os.environ.get('SSH_USER'),
passphrase=os.environ.get('SSH_PW'),
client_keys=os.environ.get('SSH_PRIVAT_KEY')) as tunnel:
listener = await tunnel.forward_local_port(
listen_host='',
listen_port=8084,
dest_host='127.0.0.1',
dest_port=5432)
conn = psycopg2.connect(
host=os.environ.get('DB_HOST'),
port=os.environ.get('DB_PORT'), # <- `local_bind_port` like in sshtunnel?
database=os.environ.get('DB_NAME'),
user=os.environ.get('DB_USER'),
password=os.environ.get('DB_PW'),
)
OUTPUT:
...
[ 2023-01-23,12:17:17.+0100 ] [INFO] logging.py - log - [conn=0] Creating local TCP forwarder from port 8084 to 127.0.0.1, port 5432
[ 2023-01-23,12:17:17.+0100 ] [INFO] logging.py - log - [conn=0] Closing connection
[ 2023-01-23,12:17:17.+0100 ] [INFO] logging.py - log - [conn=0] Sending disconnect: Disconnected by application (11)
[ 2023-01-23,12:17:17.+0100 ] [INFO] logging.py - log - [conn=0] Connection closed
Traceback (most recent call last):
File "/home/user/atlas/user_atlas/mono/tutorials/python/db_ssh_activity.py", line 135, in <module>
loop.run_until_complete(coroutine)
File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/user/atlas/user_atlas/mono/tutorials/python/db_ssh_activity.py", line 125, in main
await run_client()
File "/home/user/atlas/user_atlas/mono/tutorials/python/db_ssh_activity.py.py", line 82, in run_client
conn = psycopg2.connect(
^^^^^^^^^^^^^^^^^
File "/home/user/atlas/mono/mono_env/lib64/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
EXAMPLE 2:
Instead of connecting to my 'Server-Database Port 5432' i should connect to the tunnel port
async def run_client() -> None:
async with asyncssh.connect(
host=os.environ.get('SSH_HOST'),
known_hosts=None,
username=os.environ.get('SSH_USER'),
passphrase=os.environ.get('SSH_PW'),
client_keys=os.environ.get('SSH_PRIVAT_KEY')) as tunnel:
tunnel.forward_remote_port
listener = await tunnel.forward_local_port(
listen_host='localhost',
listen_port=1,
dest_host='127.0.0.1',
dest_port=5432)
conn = psycopg2.connect(
host='localhost',
port=listener.get_port(),
database=os.environ.get('DB_NAME'),
user=os.environ.get('DB_USER'),
password=os.environ.get('DB_PW'),
)
listener.wait_closed()
OUTPUT:
[ 2023-01-23,12:40:46.+0100 ] [INFO] logging.py - log - [conn=0] Auth for user hendrix succeeded
[ 2023-01-23,12:40:46.+0100 ] [INFO] logging.py - log - [conn=0] Creating local TCP forwarder from localhost, port 1 to 127.0.0.1, port 5432
[ 2023-01-23,12:40:46.+0100 ] [DEBUG] logging.py - log - [conn=0] Failed to create local TCP listener: [Errno 13] error while attempting to bind on address ('::1', 1, 0, 0): Permission denied
[ 2023-01-23,12:40:46.+0100 ] [INFO] logging.py - log - [conn=0] Closing connection
[ 2023-01-23,12:40:46.+0100 ] [INFO] logging.py - log - [conn=0] Sending disconnect: Disconnected by application (11)
[ 2023-01-23,12:40:46.+0100 ] [INFO] logging.py - log - [conn=0] Connection closed
Traceback (most recent call last):
File "/home/user/atlas/mono/monokapi_jupyter/tutorials/python/db_ssh_activity.py", line 136, in <module>
loop.run_until_complete(coroutine)
File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/user/atlas/user_atlas/mono/tutorials/python/db_ssh_activity.py", line 126, in main
await run_client()
File "/home/user/atlas/user_atlas/mono/tutorials/python/db_ssh_activity.py.py", line 76, in run_client
listener = await tunnel.forward_local_port(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/atlas/user_atlas/mono_env/lib64/python3.11/site-packages/asyncssh/connection.py", line 2944, in forward_local_port
listener = await create_tcp_forward_listener(self, self._loop,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/atlas/user_atlas/mono_env/lib64/python3.11/site-packages/asyncssh/listener.py", line 341, in create_tcp_forward_listener
return await create_tcp_local_listener(conn, loop, protocol_factory,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/atlas/user_atlas/mono_env/lib64/python3.11/site-packages/asyncssh/listener.py", line 314, in create_tcp_local_listener
raise OSError(exc.errno, 'error while attempting ' # type: ignore
PermissionError: [Errno 13] error while attempting to bind on address ('::1', 1, 0, 0): Permission denied

Python 3.9 - Connect to memsql

I am trying to connect to memsql (running as docker container - cluster-in-a-box). I am using Python3.9. Tried with Python 3.8 as well.
Here is the code snippet:
from memsql.common import database
conn = database.connect(host="127.0.0.1", port=3306, user="root")
print(conn.query("show databases"))
When i run this, I am getting the following error:
Traceback (most recent call last):
File "/Users/ngarg/PycharmProjects/memsqlKafka/startup_try.py", line 3, in <module>
conn = database.connect(host="127.0.0.1", port=3306, user="root")
File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 19, in connect
return Connection(*args, **kwargs)
File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 62, in __init__
self.reconnect()
File "/Users/ngarg/Library/Python/3.9/lib/python/site-packages/memsql/common/database.py", line 93, in reconnect
conn = _mysql.connect(**self._db_args)
TypeError: 'db' is an invalid keyword argument for connect()
Try to google this, but didn’t find anything. I am blocked on this step.Any help is appreciated.
When you connect from the latest version of Django to SingleStore DB, you might receive the following error message:
django.db.utils.OperationalError: (2012, 'Error in server handshake')
To connect to SingleStore DB, you will need to configure the auth_plugin in the OPTIONS field.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '{HOST}',
'NAME': '{DBNAME}',
'USER': '{USERNAME}',
'PASSWORD' : '{PASSWORD}',
'PORT': '3306',
'OPTIONS': {
'auth_plugin': 'mysql_native_password'
}
}
}
https://support.singlestore.com/hc/en-us/articles/360057857552-Connecting-Django-to-SingleStore-DB

Empty lines in multiline pattern(python error traceback) in filebeat input are not getting parsed correctly?

The log line which should be harvested and published to logstash as a single line:
[pid: 17318|app: 0|req: 1/2] 10.14.206.28 (jaavedkhan) {60 vars in 1296 bytes} [Mon Dec 30 15:51:38 2019] GET /en/ => generated 27 bytes in 711 msecs (HTTP/1.1 500) 6 headers in 316 bytes (1 switches on core 0)
Mon Dec 30 15:51:39 2019 - announcing my loyalty to the Emperor...
Internal Server Error: /en/
Traceback (most recent call last):
File "/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "./core/views.py", line 31, in get
1/0
ZeroDivisionError: division by zero
my filebeat configurations:
filebeat:
inputs:
- type: log
paths:
- "/var/log/uwsgi/vassals/dsr-incentives.log"
fields_under_root: true
multiline:
pattern: '\[pid:\s*\d*\|app:'
negate: true
match: after
fields:
log_type: app-access
appserver: uwsgi
app: dsr-incentives
server_name: server-name.domain.com
I checked the multiline pattern https://play.golang.org with the log line:
The result is as expected but the harvester is splitting the log line at "Internat server error"
Publish event: {
"#timestamp": "2019-12-30T13:02:56.564Z",
"#metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "7.5.1"
},
"log": {
"offset": 128736,
"file": {
"path": "/var/log/uwsgi/vassals/dsr-incentives.log"
},
"flags": [
"multiline"
]
},
"appserver": "uwsgi",
"server_name": "xyz",
"log_type": "app-access",
"host": {
"name": "xyz"
},
"agent": {
"hostname": "apps-1",
"id": "d3417bc3-213c-4d5e-a9b5-2273178262d0",
"version": "7.5.1",
"name": "xyz",
"type": "filebeat",
"ephemeral_id": "125578d6-44d1-4103-94bc-a1d062091487"
},
"message": "Internal Server Error: /en/\nTraceback (most recent call last):\n File \"/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/exception.py\", line 34, in inner\n response = get_response(request)\n File \"/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 126, in _get_response\n response = self.process_exception_by_middleware(e, request)\n File \"/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 124, in _get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/views/generic/base.py\", line 68, in view\n return self.dispatch(request, *args, **kwargs)\n File \"/opt/dsr-incentives/venv/lib/python3.5/site-packages/django/views/generic/base.py\", line 88, in dispatch\n return handler(request, *args, **kwargs)\n File \"./core/views.py\", line 31, in get\n 1/0\nZeroDivisionError: division by zero",
"tags": [
"filebeat"
],
"input": {
"type": "log"
},
"app": "dsr-incentives",
"ecs": {
"version": "1.1.0"
}
}
I think the problem is that the multiline is getting split at empty lines that are appearing in logs before "Internal Server Error".
Update
The log message is getting parsed correctly when there are no empty lines above "Internal Server Error"

Azure Web app up giving 'No such file or directory error'

I'm trying to add my Node.js app to azure. I have logged in using the command az login. I ran the command
az webbapp up --name azuredemoapp
This is the error that I'm getting:-
The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory: ''
Traceback (most recent call last):
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\knack\knack\cli.py", line 206, in invoke
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 603, in execute
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 661, in _run_jobs_serially
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 652, in _run_job
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\commands.py", line 55, in _polish_bad_errors
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 631, in _run_job
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 306, in __call__
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\__init__.py", line 485, in default_command_handler
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\custom.py", line 2783, in webapp_up
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\_create_util.py", line 59, in get_runtime_version_details
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\_create_util.py", line 192, in parse_netcore_version
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\xml\etree\ElementTree.py", line 1196, in parse
tree.parse(source, parser)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\xml\etree\ElementTree.py", line 586, in parse
source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: ''
To open an issue, please run: 'az feedback'
This is My package.json file
{
"name": "azuredemodeploy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Rohan Shenoy",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
The problem is most likely the way you are deploying your application, or the structure of the files in your project.
Please ensure you have a server.js or app.js in your project root. You can also specify a custom startup script in packages.json. See here for more information:
https://learn.microsoft.com/en-us/azure/app-service/deploy-local-git#prepare-your-repository

ldap3.core.exceptions.LDAPSessionTerminatedByServerError: session terminated by server

I am trying to run the code which is trying to build a connection:
server = Server(host='localhost', port=33389, use_ssl=False, get_info=ALL)
conn = Connection(server, user='uid=admin,ou=people,dc=example,dc=org', password=user-pass, raise_exceptions=False, authentication=SIMPLE)
print(server.info)
print(conn)
Below is the error detail:
None
ldap://localhost:33389 - cleartext - user: uid=admin,ou=people,dc=hadoop,dc=apache,dc=org - not lazy - unbound - closed - <no socket> - tls not started - not listening - SyncStrategy - internal decoder
**************************
Traceback (most recent call last):
File "knox_connect.py", line 116, in <module>
main()
File "knox_connect.py", line 112, in main
print(get_knox_users())
File "knox_connect.py", line 63, in get_knox_users
conn.open()
File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/sync.py", line 59, in open
self.connection.refresh_server_info()
File "/usr/local/lib/python3.5/dist-packages/ldap3/core/connection.py", line 1325, in refresh_server_info
self.server.get_info_from_server(self)
File "/usr/local/lib/python3.5/dist-packages/ldap3/core/server.py", line 448, in get_info_from_server
self._get_dsa_info(connection)
File "/usr/local/lib/python3.5/dist-packages/ldap3/core/server.py", line 364, in _get_dsa_info
get_operational_attributes=True)
File "/usr/local/lib/python3.5/dist-packages/ldap3/core/connection.py", line 775, in search
response = self.post_send_search(self.send('searchRequest', request, controls))
File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/sync.py", line 142, in post_send_search
responses, result = self.get_response(message_id)
File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/base.py", line 345, in get_response
raise LDAPSessionTerminatedByServerError(self.connection.last_error)
ldap3.core.exceptions.LDAPSessionTerminatedByServerError: session terminated by server
Any idea about the error?
You must open the connection with the conn.bind() method before reading info.
if you used print(conn.result) it will display more details with "description" and "message" where you can find the proper reason why it is terminated.
example:-
{'dn': u'', 'saslCreds': None, 'referrals': None, 'description': 'inappropriateAuthentication', 'result': 48, 'message': u'Inappropriate authentication', 'type': 'bindResponse'}
{'dn': u'', 'saslCreds': None, 'referrals': None, 'description': 'success', 'result': 0, 'message': u'', 'type': 'bindResponse'})

Resources