Query a database of MongoDB from terminal: [MongoError]: failed to connect to server - node.js

I have a web application and a database of MongoDB. Now, I just want to write scripts to query the database from terminal. I have written the following code.
const userModel = require('../models/Users');
const mongoose = require('mongoose');
const CONN = 'mongodb://tie:<password>#178.62.87.72:27017/news'
const option = {
socketTimeoutMS: 30000,
keepAlive: true,
reconnectTries: 30000,
// useNewUrlParser: true
};
mongoose.connect(CONN, option);
mongoose.connection.on('connected', async function () {
console.log('Database connected: ' + CONN);
try {
let x = await userModel.user.find({ "_id": "5a95bbc0763e1f4bad37b864" }).lean()
console.log(x)
mongoose.connection.close()
console.log("done");
} catch (error) {
console.log(error);
}
});
mongoose.connection.on('disconnected', function () {
console.log('Database disconnected:' + CONN);
});
Then, node kpi.js in the terminal returned an error:
events.js:200
throw er; // Unhandled 'error' event
^
Error [MongoError]: failed to connect to server [178.62.87.72:27017] on first connect [Error: connect ECONNREFUSED 178.62.87.72:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
name: 'MongoError',
message: 'connect ECONNREFUSED 178.62.87.72:27017'
}]
at Pool.<anonymous> (/Users/chengtie/Startup/PRODSERVER/From202005/funfun/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at Pool.emit (events.js:223:5)
at Connection.<anonymous> (/Users/chengtie/Startup/PRODSERVER/From202005/funfun/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Object.onceWrapper (events.js:313:26)
at Connection.emit (events.js:223:5)
at Socket.<anonymous> (/Users/chengtie/Startup/PRODSERVER/From202005/funfun/node_modules/mongodb-core/lib/connection/connection.js:189:49)
at Object.onceWrapper (events.js:313:26)
at Socket.emit (events.js:223:5)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Emitted 'error' event on NativeConnection instance at:
at Immediate.<anonymous> (/Users/chengtie/Startup/PRODSERVER/From202005/funfun/node_modules/mongoose/lib/connection.js:325:19)
at processImmediate (internal/timers.js:439:21) {
name: 'MongoError',
message: 'failed to connect to server [178.62.87.72:27017] on first connect [Error: connect ECONNREFUSED 178.62.87.72:27017\n' +
' at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {\n' +
" name: 'MongoError',\n" +
" message: 'connect ECONNREFUSED 178.62.87.72:27017'\n" +
'}]'
}
Does anyone know how to solve this? Do I need to use for example MongoClient?
PS: I'm able to query the database by Robo 3T with the following settings:
Edit 1: ssh tie#178.62.87.72 -nNT -v -L 27014:localhost:27017 returned:
(base) Ties-MBP:kpi chengtie$ ssh tie#178.62.87.72 -nNT -v -L 27014:localhost:27017
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 178.62.87.72 [178.62.87.72] port 22.
debug1: Connection established.
debug1: identity file /Users/chengtie/.ssh/id_rsa type 0
debug1: identity file /Users/chengtie/.ssh/id_rsa-cert type -1
debug1: identity file /Users/chengtie/.ssh/id_dsa type -1
debug1: identity file /Users/chengtie/.ssh/id_dsa-cert type -1
debug1: identity file /Users/chengtie/.ssh/id_ecdsa type -1
debug1: identity file /Users/chengtie/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/chengtie/.ssh/id_ed25519 type -1
debug1: identity file /Users/chengtie/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/chengtie/.ssh/id_xmss type -1
debug1: identity file /Users/chengtie/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13 pat OpenSSH_6.6.1* compat 0x04000002
debug1: Authenticating to 178.62.87.72:22 as 'tie'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256#libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:z8rrvKqvVmSxKFlCnb49HwUTQ/ABB9DUi9A3DUIpKtI
debug1: Host '178.62.87.72' is known and matches the ECDSA host key.
debug1: Found key in /Users/chengtie/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Users/chengtie/.ssh/id_rsa RSA SHA256:EL7hm5LvdVADZiv662nneDEeoLKy+etj8OT61eugu4Y
debug1: Will attempt key: /Users/chengtie/.ssh/id_dsa
debug1: Will attempt key: /Users/chengtie/.ssh/id_ecdsa
debug1: Will attempt key: /Users/chengtie/.ssh/id_ed25519
debug1: Will attempt key: /Users/chengtie/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/chengtie/.ssh/id_rsa RSA SHA256:EL7hm5LvdVADZiv662nneDEeoLKy+etj8OT61eugu4Y
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/chengtie/.ssh/id_dsa
debug1: Trying private key: /Users/chengtie/.ssh/id_ecdsa
debug1: Trying private key: /Users/chengtie/.ssh/id_ed25519
debug1: Trying private key: /Users/chengtie/.ssh/id_xmss
debug1: Next authentication method: password
tie#178.62.87.72's password:
debug1: Authentication succeeded (password).
Authenticated to 178.62.87.72 ([178.62.87.72]:22).
debug1: Local connections to LOCALHOST:27014 forwarded to remote address localhost:27017
debug1: Local forwarding listening on ::1 port 27014.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 27014.
debug1: channel 1: new [port listener]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: pledge: network

Your code looks fine, and we also get a response from the server of ECONNREFUSED or in english connection refused. this can be caused from several different reasons. the most common is firewall / IP issue's (which is not your case as you manage to connect using robo3T).
If you look closely in the second image you post, the ssh tab you can see a box called Use SSH Tunnel marked. this is what you're missing to be able to connect from code.
Open a new terminal tab and run something like this:
ssh user#178.62.87.72 -L [LOCAL_PORT]:localhost:27017
Where LOCAL_PORT can be any open port on your localhost. This creates an open "tunnel" being your machines and the remote machine. and this is how Mongo can communicate with you.
Then change you're connection code to this:
const CONN = 'mongodb://127.0.0.1:LOCAL_PORT'
You can keep using 27017 as your LOCAL_PORT but usually people have a running local Mongo process on that port.

Related

Unable to finish TLS handshake for my express webserver

Here's my webserver, most parts not included in favor of being concise.
server.js
const https = require('https');
const app = require('express')();
const port = 1000;
const options = {
key : getKey(),
cert: getCert(),
ciphers: getCiphers(),
passphrase: "abcd",
rejectUnauthorized: true,
requestCert: true
};
const server = https.createServer(options, app);
server.on('clientError', function (err) {
console.log('received client error');
console.log({err});
})
server.on('connection', function (err) {
console.log('client connected');
})
server.listen(port);
To test my server, I run a connection commands with openssl
openssl s_client -connect localhost:1000 \
-servername localhost \
-CAfile etc/root-cert/ca.cert.pem \
-cert etc/certs/client.cert.pem \
-key etc/private/client.key.pem
This returns the following output, which indicates that the TLS connection was successful (as far as I'm aware):
CONNECTED(00000005)
depth=2 C = US, ST = California, O = Hackysack, CN = Hackysack Root CA
verify return:1
depth=1 C = US, ST = California, O = Hackysack, CN = Hackysack Intermediate CA
verify return:1
depth=0 C = US, ST = California, O = Hackysack, CN = localhost
verify return:1
write W BLOCK
---
Certificate chain
0 s:/C=US/ST=California/O=Hackysack/CN=localhost
i:/C=US/ST=California/O=Hackysack/CN=Hackysack Intermediate CA
1 s:/C=US/ST=California/O=Hackysack/CN=Hackysack Intermediate CA
i:/C=US/ST=California/O=Hackysack/CN=Hackysack Root CA
---
Server certificate
-----BEGIN CERTIFICATE-----
[Long cert file here]
-----END CERTIFICATE-----
subject=/C=US/ST=California/O=Hackysack/CN=localhost
issuer=/C=US/ST=California/O=Hackysack/CN=Hackysack Intermediate CA
---
No client certificate CA names sent
Server Temp Key: ECDH, X25519, 253 bits
---
SSL handshake has read 3400 bytes and written 2061 bytes
---
New, TLSv1/SSLv3, Cipher is AEAD-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.3
Cipher : AEAD-AES128-GCM-SHA256
Session-ID:
Session-ID-ctx:
Master-Key:
Start Time: 1674855496
Timeout : 7200 (sec)
Verify return code: 0 (ok)
---
read:errno=0
However, in my server terminal logs I see that I receive a clientError when trying to make this call via HTTPS request.
{
err: Error: socket hang up
at connResetException (internal/errors.js:639:14)
at TLSSocket.onSocketClose (_tls_wrap.js:1063:23)
at TLSSocket.emit (events.js:412:35)
at net.js:686:12
at Socket.done (_tls_wrap.js:564:7)
at Object.onceWrapper (events.js:520:26)
at Socket.emit (events.js:400:28)
at TCP.<anonymous> (net.js:686:12) {
code: 'ECONNRESET'
}
}
Here's my client request:
const https = require('https');
const options = {
hostname: 'localhost',
port: 1000,
method: "POST",
path: "/test",
cert: getClientCert(),
key: getClientKey(),
passphrase: "abcd",
ciphers: getCiphers()
ca: getCA(),
}
const request = https.request(options);
I noticed this error only started happening when I included requestCert: true when I created the server. I think something must be going wrong with my client side for this to be the case. The main problem with debugging this is that I'm not receiving a good error when it fails the handshake.
How can I better debug this issue?

Axios/HTTPS certificate expired error only on Windows

I am currently working on a VSCode extension that internally makes some API calls to a HTTPS protected endpoint. On Linux and Mac OS the extension works as expected but on Windows machines axios, the internal HTTP client used to make the API calls, is rejecting those requests due to the certificates being expired. When I access the API endpoint though via Firefox, Chrome and even Edge the certificates seems find.
I have upgraded Node to 16.14.0 and also to 17.6.0 but the problem still remains. As the API is only accessible through our VPN, with my VPN activated of course, I used testssl.sh to verify that the whole trust-chain is still valid:
Testing protocols via sockets except NPN+ALPN
SSLv2 not offered (OK)
SSLv3 not offered (OK)
TLS 1 not offered
TLS 1.1 not offered
TLS 1.2 offered (OK)
TLS 1.3 offered (OK): final
NPN/SPDY not offered
ALPN/HTTP2 h2, http/1.1 (offered)
Testing cipher categories
NULL ciphers (no encryption) not offered (OK)
Anonymous NULL Ciphers (no authentication) not offered (OK)
Export ciphers (w/o ADH+NULL) not offered (OK)
LOW: 64 Bit + DES, RC[2,4] (w/o export) not offered (OK)
Triple DES Ciphers / IDEA not offered
Obsolete CBC ciphers (AES, ARIA etc.) offered
Strong encryption (AEAD ciphers) offered (OK)
Testing robust (perfect) forward secrecy, (P)FS -- omitting Null Authentication/Encryption, 3DES, RC4
PFS is offered (OK) TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-SHA384 ECDHE-RSA-AES256-SHA
DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES256-SHA256 DHE-RSA-AES256-SHA TLS_AES_128_GCM_SHA256 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES128-SHA256
ECDHE-RSA-AES128-SHA DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES128-SHA256 DHE-RSA-AES128-SHA
Elliptic curves offered: prime256v1 secp384r1 secp521r1 X25519 X448
DH group offered: HAProxy (2048 bits)
Testing server preferences
Has server cipher order? yes (OK) -- TLS 1.3 and below
Negotiated protocol TLSv1.3
Negotiated cipher TLS_AES_256_GCM_SHA384, 253 bit ECDH (X25519)
Cipher order
TLSv1.2: ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES128-SHA
ECDHE-RSA-AES256-SHA384 ECDHE-RSA-AES256-SHA DHE-RSA-AES128-SHA256 DHE-RSA-AES128-SHA DHE-RSA-AES256-SHA256 DHE-RSA-AES256-SHA
TLSv1.3: TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256 TLS_AES_128_GCM_SHA256
...
Certificate Validity (UTC) 65 >= 30 days (2022-02-01 08:18 --> 2022-05-02 08:18)
...
The other certificates in the trustchain are also valid and not expired at all.
Axios is used within an own HttpClient class that looks like this:
export class HttpClient {
private readonly instance: AxiosInstance;
constructor() {
this.instance = axios.create();
}
async asyncGet<T>(url: string): Promise<Response<T>> {
return this.instance.get<T>(url)
.then(axiosResponse => {
...
})
.catch(error => {
console.error(error);
throw error;
});
}
}
I also tried the https
const options: https:RequestOptions = {
hostname: '...',
port: 443,
path: '/...',
method: 'GET'
};
const request = https.request(url, options, (res: IncomingMessage) => {
console.log(`statusCode: ${res.statusCode ? res.statusCode : 'undefined'}`);
res.on('data', d => {
process.stdout.write(d as string);
}
});
request.on('error', error => {
console.error(error);
};
request.end();
analog to the samples given in the NodeJS documentation and tls
const socket = tls.connect(443, hostname, undefined, () => {
console.log('Connected to ' + hostname);
console.log('TLS.connect', socket.authorized ? 'authorized' : 'unauthorized');
console.log('Cipher: ' + JSON.stringify(socket.getCipher()));
console.log('Protocol: ' + JSON.stringify(socket.getProtocol()));
const peerCert: tls.DetailedPeerCertificate = socket.getPeerCertificate(true);
console.log(`Peer-Cert ${JSON.stringify(peerCert.subject)} - valid from: ${peerCert ? peerCert.valid_from : 'invalid'} valid till: ${peerCert ? peerCert.valid_to : 'invalid'}`);
const issuerCert = peerCert.issuerCertificate;
console.log(`issuer-Cert ${JSON.stringify(issuerCert.subject)} - valid from: ${issuerCert ? issuerCert.valid_from : 'invalid'} valid till: ${issuerCert ? issuerCert.valid_to : 'invalid'}`);
const rootCert = issuerCert.issuerCertificate;
console.log(`root-Cert ${JSON.stringify(rootCert.subject)} - valid from: ${rootCert ? rootCert.valid_from : 'invalid'} valid till: ${rootCert ? rootCert.valid_to : 'invalid'}`);
});
as proposed in this answer.
Both axios and https return an error like this:
{
"message": "certificate has expired",
"name": "Error",
"stack": "Error: certificate has expired\n\tat TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)\n\tat TLSSocket.emit (events.js:315:20)\n\tat TLSSocket._finishInit (_tls_wrap.js:932:8)\n\tat TLSWrap.onhandshakedone (_tls_wrap.js:706:12)\n\tat TLSWrap.callbackTrampoline (internal/async_hooks.js:131:14)",
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"transformRequest": [
"null"
],
"transformResponse": [
"null"
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1,
"headers": {
"Accept": "application/json, text/plain, */*",
"user-Agent": "axios/0.26.0"
},
"method": "get",
"url": "https://..."
},
"code": "CERT_HAS_EXPIRED",
"status": null
}
with a more human-readable stacktrace:
Error: certificate has expired
at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
at TLSSocket.emit (events.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:932:8)
at TLSWrap.onhandshakedone (_tls_wrap.js:706:12)
at TLSWrap.callbackTrampoline (internal/async_hooks.js:131:14)
while for tls I get the following output:
Connected to ...
TLS.connect authorized
Cipher: {"name":"TLS_CHACHA20_POLY1305_SHA256","standardName":"TLS_CHACHA20_POLY1305_SHA256","version":"TLSv1/SSLv3"}
Protocol: "TLSv1.3"
Peer-Cert {"CN": "*...."} - valid from: Feb 1 08:18:23 2022 GMT valid till: May 2 08:18:22 2022 GMT
issuer-Cert {"C":"US","O":"Let's Encrypt","CN":"R3"} - valid from Sep 4 00:00:00 2020 GMT valid till: Sep 15 16:00:00 2025 GMT
root-Cert {"C":"US","O":"Internet Security Research Group","CN":"ISRG Root X1"} - valid from: Jan 20 19:14:03 2021 GMT valid till: Sep 30 18:14:03 2024 GMT
So tls seems to be able to connect to the API server and perform the SSL/TLS handshake, but https and axios somehow fail.
I also stumbled upon this question here, which seems to be related, but as I am already on the latest NodeJS release (as well as any dependency used in the extension is on the most recent version) and this error only occurs on Windows (mostly 10, unsure if and how many users actually use Windows 11) machines I think the question deserves its own spot here on SO.
In order to rule out a lack of common supported ciphers between the Windows and Node.js based tls implementation and the nginx managed server side, I also checked the available ciphers in Node via node -p crypto.constants.defaultCoreCipherList which returns a list like this:
TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
TLS_AES_128_GCM_SHA256
ECDHE-RSA-AES128-GCM-SHA256
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-AES256-GCM-SHA384
DHE-RSA-AES128-GCM-SHA256
ECDHE-RSA-AES128-SHA256
DHE-RSA-AES128-SHA256
ECDHE-RSA-AES256-SHA384
DHE-RSA-AES256-SHA384
ECDHE-RSA-AES256-SHA256
DHE-RSA-AES256-SHA256
HIGH
!aNULL
!eNULL
!EXPORT
!DES
!RC4
!MD5
!PSK
!SRP
!CAMELLIA
which indicates that enough ciphers would overlap between client and server.
Why do I still get a certificate expired error on Windows machines with axios/https
when Linux and MacOS work just fine with these settings and tls is able to connect to the remote API sucessfully even on Windows machines?

pygatt connects but unable to subscribe vs. bleak connects and able to subscribe: why isn't bleak replicable with pygatt?

I am trying to subscribe to single characteristic on a BLE device. Using bleak I am able to connect to the device and then write / subscribe to characteristics. With virtually identical code using pygatt, I can connect to the same device using my BLED112 dongle, but am not able to write/subscribe to that same characteristic.
bleak test program:
import sys
import os
import asyncio
import aioconsole
from bleak import BleakClient
ADDRESS = '28686572-5A71-435E-952A-6F4292F5B04A'
#ADDRESS = '00:55:DA:B7:98:9C'
CHARACTERISTIC_UUID = '273e0003-4c4d-454d-96be-f03bac821358'
if len(sys.argv) == 3:
ADDRESS = sys.argv[1]
CHARACTERISTIC_UUID = sys.argv[2]
def notification_handler(sender, data):
"""Simple notification handler which prints the data received."""
print("{0}: {1}".format(sender, data))
async def run(address):
async with BleakClient(address) as client:
await client.connect()
print("Is connected")
# start notifications on control characteristic
await client.start_notify('273e0001-4c4d-454d-96be-f03bac821358', notification_handler)
# write to control handle, set preset to 21
await client.write_gatt_char('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x04, 0x70, 0x32, 0x31, 0x0a]), False)
# write to control handle get device info
await client.write_gatt_char('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x03, 0x76, 0x31, 0x0a]), False)
# write to control handle for resume
await client.write_gatt_char('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x02, 0x64, 0x0a]), False)
# start notifications on TP9
await client.start_notify('273e0003-4c4d-454d-96be-f03bac821358', notification_handler)
# wait for input
await aioconsole.ainput('Running: Press a key to quit')
await client.stop_notify('273e0003-4c4d-454d-96be-f03bac821358')
if __name__ == "__main__":
os.environ["PYTHONASYNCIODEBUG"] = str(1)
loop = asyncio.get_event_loop()
loop.run_until_complete(run(ADDRESS))
Output:
$ python3 bleaktest.py
Is connected
13: bytearray(b'\x08{"rc":0}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
13: bytearray(b'\x10{"ap":"headset",\x00\x00\x00')
13: bytearray(b'\x13"sp":"Blackcomb_rev')
13: bytearray(b'\x03B",":"Blackcomb_rev')
13: bytearray(b'\x10"tp":"consumer",rev')
13: bytearray(b'\x0c"hw":"10.6",er",rev')
13: bytearray(b'\x07"bn":2,0.6",er",rev')
13: bytearray(b'\x0e"fw":"1.0.21",",rev')
13: bytearray(b'\r"bl":"1.0.0",,",rev')
13: bytearray(b'\x07"pv":1,.0.0",,",rev')
13: bytearray(b'\x07"rc":0}.0.0",,",rev')
Running: Press a key to quit
13: bytearray(b'\x08{"rc":0}0.0",,",rev')
31: bytearray(b'\x00\x00\x80\x08\x00z\xa8\xdfL#\x00\xa8!\xb6p\xa0\x00hA\x92')
31: bytearray(b'\x00\x01\x9d0\x00]q\x86\xb5\xb0\x00+\xaf\x96\xf3#\x1a\x00\t\x88')
31: bytearray(b'\x00\x02\x1bh\x04\x00\x06\x14\x18\t\xe8\x00\x05&\x13\xdc%\x00\x01\x97')
...
31: bytearray(b'\x00\x19_\xf1\x85\x9e\xc0\x00GP\xe9\xcb#\x00\t\x9c\xaf\x11\x15\xe4')
...
As you can see from the output, the writes are successful because of the response handles. And the subscriptions are clearly functional given the responses from both the control characteristic and the secondary characteristic.
pygatt test program:
import pygatt
import time
from binascii import hexlify
from pygatt.backends.backend import BLEAddressType
def handle_data(handle, data):
"""
handle -- integer, characteristic read handle the data was received on
raw_value -- bytearray, the data returned in the notification
"""
print(hexlify(data))
#adapter = pygatt.GATTToolBackend('hci0') linux backend
adapter = pygatt.BGAPIBackend()
try:
adapter.start()
device = adapter.connect('00:55:DA:B7:98:9C', address_type = BLEAddressType.public)
print("Is connected")
# start notifications on control characteristic
device.subscribe('273e0001-4c4d-454d-96be-f03bac821358', callback = handle_data, wait_for_response = True)
# write to control handle, set preset to 21
device.char_write('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x04, 0x70, 0x32, 0x31, 0x0a]), wait_for_response = True)
# write to control handle get device info
device.char_write('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x03, 0x76, 0x31, 0x0a]), wait_for_response = True)
# write to control handle for resume
device.char_write('273e0001-4c4d-454d-96be-f03bac821358', bytearray([0x02, 0x64, 0x0a]), wait_for_response = True)
time.sleep(5)
# subscribe to eeg characteristic
device.subscribe('273e0003-4c4d-454d-96be-f03bac821358', callback = handle_data, indication = False, wait_for_response = True)
time.sleep(5)
finally:
print("Adapter stopped")
adapter.stop()
Output:
$ python3 pygatttest.py
Is connected
Adapter stopped
The pygatt program is able to connect to the device (I can see the indicator light change states from flashing to solid), but subscription fails. I don't know if char_write is working because I don't receive a return notification. Am in the process of trying the logging module to figure out more per the comments below.
Updated output with logging enabled:
$ python3 pygatttest.py
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 4 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.Bluetooth-Incoming-Port - n/a
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.usbmodem11 - Low Energy Dongle - CDC data
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC data VID=0x2458 PID=0x0001 on /dev/cu.usbmodem11
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/cu.usbmodem11
INFO:pygatt.backends.bgapi.bgapi:Resetting and reconnecting to device for a clean environment
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 4 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.Bluetooth-Incoming-Port - n/a
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.usbmodem11 - Low Energy Dongle - CDC data
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC data VID=0x2458 PID=0x0001 on /dev/cu.usbmodem11
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/cu.usbmodem11
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 1)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 3 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.Bluetooth-Incoming-Port - n/a
DEBUG:pygatt.backends.bgapi.bgapi:Failed to open serial port
Traceback (most recent call last):
File ".../pygatt/backends/bgapi/bgapi.py", line 171, in _open_serial_port
serial_port = self._serial_port or self._detect_device_port()
File ".../pygatt/backends/bgapi/bgapi.py", line 147, in _detect_device_port
raise BGAPIError("Unable to auto-detect BLED112 serial port")
pygatt.backends.bgapi.exceptions.BGAPIError: Unable to auto-detect BLED112 serial port
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 2)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 3 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.Bluetooth-Incoming-Port - n/a
...
DEBUG:pygatt.backends.bgapi.bgapi:Failed to open serial port
Traceback (most recent call last):
File ".../pygatt/backends/bgapi/bgapi.py", line 171, in _open_serial_port
serial_port = self._serial_port or self._detect_device_port()
File ".../pygatt/backends/bgapi/bgapi.py", line 147, in _detect_device_port
raise BGAPIError("Unable to auto-detect BLED112 serial port")
pygatt.backends.bgapi.exceptions.BGAPIError: Unable to auto-detect BLED112 serial port
DEBUG:pygatt.backends.bgapi.bgapi:Opening connection to serial port (attempt 3)
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
DEBUG:pygatt.backends.bgapi.util:Found 4 serial USB devices
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.Bluetooth-Incoming-Port - n/a
...
DEBUG:pygatt.backends.bgapi.util:Checking serial USB device: /dev/cu.usbmodem11 - Low Energy Dongle - CDC data
DEBUG:pygatt.backends.bgapi.util:USB device: Low Energy Dongle - CDC data VID=0x2458 PID=0x0001 on /dev/cu.usbmodem11
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/cu.usbmodem11
INFO:pygatt.backends.bgapi.bgapi:Running receiver
INFO:pygatt.backends.bgapi.bgapi:Disabling advertising
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.gap_set_mode: 58>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.gap_set_mode packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.sm_set_bondable_mode: 51>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.sm_set_bondable_mode packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Stopping any outstanding GAP procedure
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.gap_end_procedure: 61>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.gap_end_procedure packet: Device in wrong state
INFO:pygatt.backends.bgapi.bgapi:Connecting to device at address 00:55:DA:B7:98:9C (timeout 5s)
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.sm_set_bondable_mode: 51>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.sm_set_bondable_mode packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.gap_connect_direct: 60>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.gap_connect_direct packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.connection_status: 11>] within 5.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.connection_status packet: Success
INFO:pygatt.backends.bgapi.bgapi:Connection status: handle=0x0, flags=5, address=0xb'9c98b7da5500', connection interval=75.000000ms, timeout=1000, latency=0 intervals, bonding=0xff
INFO:pygatt.backends.bgapi.bgapi:Connected to 00:55:DA:B7:98:9C
Is connected
DEBUG:pygatt.device:Looking up handle for characteristic 273e0001-4c4d-454d-96be-f03bac821358
INFO:pygatt.backends.bgapi.bgapi:Fetching characteristics for connection 0
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_find_information: 41>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_find_information packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a05-0000-1000-8000-00805f9b34fb
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a00-0000-1000-8000-00805f9b34fb
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a01-0000-1000-8000-00805f9b34fb
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found approved characteristic 00002a04-0000-1000-8000-00805f9b34fb
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0001-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0008-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0009-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000a-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000b-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0002-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0003-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0004-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0005-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0006-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0007-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000c-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
cDEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000d-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000e-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e000f-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0010-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
INFO:pygatt.backends.bgapi.bgapi:Found custom characteristic 273e0011-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_find_information_found packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a05-0000-1000-8000-00805f9b34fb is handle 0x3
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x4
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a00-0000-1000-8000-00805f9b34fb is handle 0x7
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a01-0000-1000-8000-00805f9b34fb is handle 0x9
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x00002a04-0000-1000-8000-00805f9b34fb is handle 0xb
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0001-4c4d-454d-96be-f03bac821358 is handle 0xe
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0xf
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0008-4c4d-454d-96be-f03bac821358 is handle 0x11
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x12
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0009-4c4d-454d-96be-f03bac821358 is handle 0x14
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x15
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000a-4c4d-454d-96be-f03bac821358 is handle 0x17
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x18
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000b-4c4d-454d-96be-f03bac821358 is handle 0x1a
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x1b
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0002-4c4d-454d-96be-f03bac821358 is handle 0x1d
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x1e
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0003-4c4d-454d-96be-f03bac821358 is handle 0x20
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x21
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0004-4c4d-454d-96be-f03bac821358 is handle 0x23
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x24
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0005-4c4d-454d-96be-f03bac821358 is handle 0x26
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x27
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0006-4c4d-454d-96be-f03bac821358 is handle 0x29
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x2a
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0007-4c4d-454d-96be-f03bac821358 is handle 0x2c
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x2d
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000c-4c4d-454d-96be-f03bac821358 is handle 0x2f
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x30
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000d-4c4d-454d-96be-f03bac821358 is handle 0x32
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x33
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000e-4c4d-454d-96be-f03bac821358 is handle 0x35
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x36
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e000f-4c4d-454d-96be-f03bac821358 is handle 0x38
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x39
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0010-4c4d-454d-96be-f03bac821358 is handle 0x3b
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x3c
INFO:pygatt.backends.bgapi.bgapi:Characteristic 0x273e0011-4c4d-454d-96be-f03bac821358 is handle 0x3e
INFO:pygatt.backends.bgapi.bgapi:Characteristic descriptor 0x00002902-0000-1000-8000-00805f9b34fb is handle 0x3f
DEBUG:pygatt.device:Found <Characteristic uuid=273e0001-4c4d-454d-96be-f03bac821358 handle=14>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Success
INFO:pygatt.device:Subscribed to uuid=273e0001-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.device:Looking up handle for characteristic 273e0001-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.device:Found <Characteristic uuid=273e0001-4c4d-454d-96be-f03bac821358 handle=14>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Write not permitted
DEBUG:pygatt.device:Looking up handle for characteristic 273e0001-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.device:Found <Characteristic uuid=273e0001-4c4d-454d-96be-f03bac821358 handle=14>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Write not permitted
DEBUG:pygatt.device:Looking up handle for characteristic 273e0001-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.device:Found <Characteristic uuid=273e0001-4c4d-454d-96be-f03bac821358 handle=14>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.attclient_procedure_completed packet: Write not permitted
DEBUG:pygatt.device:Looking up handle for characteristic 273e0003-4c4d-454d-96be-f03bac821358
DEBUG:pygatt.device:Found <Characteristic uuid=273e0003-4c4d-454d-96be-f03bac821358 handle=32>
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<ResponsePacketType.attclient_attribute_write: 43>] within 1.000000s
DEBUG:pygatt.backends.bgapi.bgapi:Received a EventPacketType.connection_disconnected packet: Success
DEBUG:pygatt.backends.bgapi.bgapi:Received a ResponsePacketType.attclient_attribute_write packet: Not connected
DEBUG:pygatt.backends.bgapi.bgapi:Expecting a response of one of [<EventPacketType.attclient_procedure_completed: 17>] within 30.000000s
Adapter stopped
INFO:pygatt.backends.bgapi.bgapi:Stopping
INFO:pygatt.backends.bgapi.bgapi:Stopping receiver
I'm not sure if I'm interpreting this information correctly, but it seems as if the subscription is working and that I'm receiving information but the callback is not being fired?
I tried the solution here: pygatt: Unable to execute device.subscribe() by adding the time.sleep() lines to my code, but the output did not change.
How can I translate my bleak program to pygatt and subscribe successfully using pygatt?

curl cannot handshake https server created with Nodejs v14.16.0 tls.createSecureContext

I have set up a HTTPS server (nodejs v14.16.0) and certificates from letsEncrypt (which work in the current version of the app that uses https.createServer). Unfortunately, curl cannot connect successfully to my HTTPS server. I get the following error
routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Here's a minimum reproducible version of my server
const https = require('https')
const tls = require('tls');
const fs = require('fs');
const constants = require('constants');
tls.DEFAULT_ECDH_CURVE = "auto"
require('dotenv').config()
const certOpts = {
key: `${process.env.KEY_PATH}/privkey.pem`,
cert: `${process.env.KEY_PATH}/cert.pem`,
ca: `${process.env.KEY_PATH}/chain.pem`,
};
/**
*
* #param {Record<string, string>} filePathMap
* #returns {Record<string, Buffer>}
*/
function getBuffersFromFilePathMap(filePathMap) {
const bufferMap = {}
for (const path in filePathMap) {
if (Object.hasOwnProperty.call(filePathMap, path)) {
bufferMap[path] = fs.readFileSync(filePathMap[path]);
}
}
return bufferMap;
}
const buffers = getBuffersFromFilePathMap(certOpts);
function createContext() {
return tls.createSecureContext({
...buffers,
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1,
maxVersion:'TLSv1.2'
});
}
const server = https.createServer({ secureContext: createContext() }, (req, res) => {
// eslint-disable-next-line no-console
console.log('connect');
res.writeHead(200);
res.write('Hello World!\n');
res.end('Goodbye World!\n');
});
server.listen(9999, () => console.log('Server up: ', server.address()));
This is the output of curl --version
curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.0.2k zlib/1.2.8 libidn2/2.3.0 libpsl/0.6.2 (+libicu/50.1.2) libssh2/1.4.2 nghttp2/1.31.1
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy PSL
From what I've gathered, ssl3 may not be supported .
Output from curl
$ curl -k https://localhost:9999
curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Curl traces
== Info: Rebuilt URL to: https://localhost:9999/
== Info: Trying 127.0.0.1...
== Info: TCP_NODELAY set
== Info: Connected to localhost (127.0.0.1) port 9999 (#0)
== Info: ALPN, offering h2
== Info: ALPN, offering http/1.1
== Info: Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:#STRENGTH
== Info: successfully set certificate verify locations:
== Info: CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
== Info: TLSv1.2 (OUT), TLS header, Certificate Status (22):
=> Send SSL data, 5 bytes (0x5)
0000: .....
== Info: TLSv1.2 (OUT), TLS handshake, Client hello (1):
=> Send SSL data, 512 bytes (0x200)
0000: .......*.c....}.5.H>^..e\;)}.zEW.....d....0.,.(.$.............k.
0040: j.i.h.9.8.7.6.........2...*.&.......=.5.../.+.'.#.............g.
0080: #.?.>.3.2.1.0.........E.D.C.B.1.-.).%.......<./...A.............
00c0: ............3.........localhost......................... .......
0100: ..............................3t.........h2.http/1.1............
0140: ................................................................
0180: ................................................................
01c0: ................................................................
== Info: TLSv1.2 (IN), TLS header, Unknown (21):
<= Recv SSL data, 5 bytes (0x5)
0000: .....
== Info: TLSv1.2 (IN), TLS alert, handshake failure (552):
<= Recv SSL data, 2 bytes (0x2)
0000: .(
== Info: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Okay, it appears that even though the documentation for tls.createSecureContext says the result is "usable as an argument to several tls APIs, such as tls.createServer" it actually isn't. It is accepted by server.addContext (for a virtual host or more exactly an SNI-value handler) tls.connect (for client) tls.createSecurePair (deprecated) and new TLSSocket (low-level), but createServer only takes the same options as createSecureContext not an actual SecureContext. Since you didn't supply the needed key&cert in a usable form, and OpenSSL by default disables anonymous ciphersuites (which most clients don't offer anyway), all handshakes fail with no_shared_cipher. Try:
const server = https.createServer(
{...buffers,
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1,
maxVersion:'TLSv1.2' },
(req, res) => stuff )
BTW the req,res=> function is invoked when you get a request not a connection as such; a proper client will only connect when it needs to do a request, but it is possible to connect without doing a request, and conversely fine to do multiple requests on one connection.

SSH times out while connecting via ipv6 but works with ipv4 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Yesterday I reinstalled my Ubuntu (for unrelated reasons) and since then ssh behaves very weirdly.
It takes suuuper long to connect (multiple minutes). Using -vvv I found that it first tries to connect using an ipv6 (which times out) and after that tries to connect via ipv4 which works almost instantly.
I never had any issues with ssh before.
running
ssh login#address.net -vvv
(with the address I want to connect to) returns
OpenSSH_8.2p1 Ubuntu-4, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving "address.net" port 22
debug2: ssh_connect_direct
debug1: Connecting to address.net [*:*:*:*::*] port 22.
debug1: connect to address *:*:*:*::* port 22: Connection timed out
debug1: Connecting to address.net [*.*.*.*] port 22.
debug1: Connection established.
debug1: identity file /home/malte/.ssh/id_rsa type 0
debug1: identity file /home/malte/.ssh/id_rsa-cert type -1
debug1: identity file /home/malte/.ssh/id_dsa type -1
debug1: identity file /home/malte/.ssh/id_dsa-cert type -1
debug1: identity file /home/malte/.ssh/id_ecdsa type -1
debug1: identity file /home/malte/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/malte/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/malte/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/malte/.ssh/id_ed25519 type -1
debug1: identity file /home/malte/.ssh/id_ed25519-cert type -1
debug1: identity file /home/malte/.ssh/id_ed25519_sk type -1
debug1: identity file /home/malte/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/malte/.ssh/id_xmss type -1
debug1: identity file /home/malte/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to login.caps.in.tum.de:22 as 'ehren'
debug3: hostkeys_foreach: reading file "/home/malte/.ssh/known_hosts"
debug3: record_hostkey: found key type ED25519 in file /home/malte/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from login.caps.in.tum.de
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-ed25519-cert-v01#openssh.com,ssh-ed25519
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256#libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: ssh-ed25519-cert-v01#openssh.com,ssh-ed25519,ecdsa-sha2-nistp256-cert-v01#openssh.com,ecdsa-sha2-nistp384-cert-v01#openssh.com,ecdsa-sha2-nistp521-cert-v01#openssh.com,sk-ecdsa-sha2-nistp256-cert-v01#openssh.com,sk-ssh-ed25519-cert-v01#openssh.com,rsa-sha2-512-cert-v01#openssh.com,rsa-sha2-256-cert-v01#openssh.com,ssh-rsa-cert-v01#openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256#openssh.com,sk-ssh-ed25519#openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305#openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm#openssh.com,aes256-gcm#openssh.com
debug2: ciphers stoc: chacha20-poly1305#openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm#openssh.com,aes256-gcm#openssh.com
debug2: MACs ctos: umac-64-etm#openssh.com,umac-128-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512-etm#openssh.com,hmac-sha1-etm#openssh.com,umac-64#openssh.com,umac-128#openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm#openssh.com,umac-128-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512-etm#openssh.com,hmac-sha1-etm#openssh.com,umac-64#openssh.com,umac-128#openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib#openssh.com,zlib
debug2: compression stoc: none,zlib#openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256#libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519,ssh-ed25519-cert-v01#openssh.com
debug2: ciphers ctos: chacha20-poly1305#openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm#openssh.com,aes256-gcm#openssh.com
debug2: ciphers stoc: chacha20-poly1305#openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm#openssh.com,aes256-gcm#openssh.com
debug2: MACs ctos: umac-64-etm#openssh.com,umac-128-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512-etm#openssh.com,hmac-sha1-etm#openssh.com,umac-64#openssh.com,umac-128#openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm#openssh.com,umac-128-etm#openssh.com,hmac-sha2-256-etm#openssh.com,hmac-sha2-512-etm#openssh.com,hmac-sha1-etm#openssh.com,umac-64#openssh.com,umac-128#openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib#openssh.com
debug2: compression stoc: none,zlib#openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519-cert-v01#openssh.com
debug1: kex: server->client cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305#openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host certificate: ssh-ed25519-cert-v01#openssh.com SHA256:3rfJzCTfq9xb2UYjwCf+FLMo5s46IDcAeKWN4OEN9Qw, serial 0 ID "host:intum:vmschulz30" CA ssh-ed25519 SHA256:xw6Z8D0o6klmmOcnCzhqhTkitvGcjuuQ9JsunW4bvm8 valid forever
debug2: Server host certificate hostname: vmschulz30
debug2: Server host certificate hostname: vmschulz30.in.tum.de
debug3: hostkeys_foreach: reading file "/home/malte/.ssh/known_hosts"
debug3: record_hostkey: found key type ED25519 in file /home/malte/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from login.caps.in.tum.de
debug1: No matching CA found. Retry with plain key
debug1: Host 'login.caps.in.tum.de' is known and matches the ED25519 host key.
debug1: Found key in /home/malte/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/malte/.ssh/id_rsa RSA SHA256:nmOOjBiUCmQEF8b08sB9LIwjSfwxA03cRStE6BrNe2g agent
debug1: Will attempt key: /home/malte/.ssh/id_dsa
debug1: Will attempt key: /home/malte/.ssh/id_ecdsa
debug1: Will attempt key: /home/malte/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/malte/.ssh/id_ed25519
debug1: Will attempt key: /home/malte/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/malte/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/malte/.ssh/id_rsa RSA SHA256:nmOOjBiUCmQEF8b08sB9LIwjSfwxA03cRStE6BrNe2g agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/malte/.ssh/id_dsa
debug3: no such identity: /home/malte/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/malte/.ssh/id_ecdsa
debug3: no such identity: /home/malte/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/malte/.ssh/id_ecdsa_sk
debug3: no such identity: /home/malte/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/malte/.ssh/id_ed25519
debug3: no such identity: /home/malte/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/malte/.ssh/id_ed25519_sk
debug3: no such identity: /home/malte/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/malte/.ssh/id_xmss
debug3: no such identity: /home/malte/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
login#address.net's password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to address.net ([*.*.*.*]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions#openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00#openssh.com want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env SHELL
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env QT_ACCESSIBILITY
debug3: Ignored env COLORTERM
debug3: Ignored env XDG_CONFIG_DIRS
debug3: Ignored env XDG_MENU_PREFIX
debug3: Ignored env GNOME_DESKTOP_SESSION_ID
debug3: Ignored env GTK_IM_MODULE
debug3: Ignored env QT4_IM_MODULE
debug1: Sending env LC_ADDRESS = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env GNOME_SHELL_SESSION_MODE
debug1: Sending env LC_NAME = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env XMODIFIERS
debug3: Ignored env DESKTOP_SESSION
debug1: Sending env LC_MONETARY = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env SSH_AGENT_PID
debug3: Ignored env GTK_MODULES
debug3: Ignored env PWD
debug3: Ignored env LOGNAME
debug3: Ignored env XDG_SESSION_DESKTOP
debug3: Ignored env XDG_SESSION_TYPE
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env XAUTHORITY
debug3: Ignored env GJS_DEBUG_TOPICS
debug3: Ignored env WINDOWPATH
debug3: Ignored env HOME
debug3: Ignored env USERNAME
debug3: Ignored env IM_CONFIG_PHASE
debug1: Sending env LC_PAPER = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env LS_COLORS
debug3: Ignored env XDG_CURRENT_DESKTOP
debug3: Ignored env VTE_VERSION
debug3: Ignored env GNOME_TERMINAL_SCREEN
debug3: Ignored env INVOCATION_ID
debug3: Ignored env MANAGERPID
debug3: Ignored env CLUTTER_IM_MODULE
debug3: Ignored env GJS_DEBUG_OUTPUT
debug3: Ignored env LESSCLOSE
debug3: Ignored env XDG_SESSION_CLASS
debug3: Ignored env TERM
debug1: Sending env LC_IDENTIFICATION = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env LESSOPEN
debug3: Ignored env USER
debug3: Ignored env GNOME_TERMINAL_SERVICE
debug3: Ignored env DISPLAY
debug3: Ignored env SHLVL
debug1: Sending env LC_TELEPHONE = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env QT_IM_MODULE
debug1: Sending env LC_MEASUREMENT = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env XDG_RUNTIME_DIR
debug1: Sending env LC_TIME = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env JOURNAL_STREAM
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env PATH
debug3: Ignored env GDMSESSION
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug1: Sending env LC_NUMERIC = de_DE.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
annoyling this happens will all servers I try to connect to and also affects git (over ssh)
thanks in advance for any hints as to what the issue could be <3
The symptom suggests that after the reinstall there's a different ssh config; check /etc/ssh/ssh_config for AddressFamily set to any; you could set to inet there or privately in ~/.ssh/config

Resources