questdb / py-questdb-client

Python client for QuestDB InfluxDB Line Protocol
https://py-questdb-client.readthedocs.io
Apache License 2.0
55 stars 10 forks source link

Client does not disconnect on failed authentication #49

Closed ideoma closed 9 months ago

ideoma commented 1 year ago

When I create cloud QuestDB instance an use the code example to send data (slightly modified):


# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
from questdb.ingress import Sender, IngressError, TimestampNanos
import datetime

def example(host: str = 'blabla.questdb.net', port: int = 30906):
    # See: https://questdb.io/docs/reference/api/ilp/authenticate
    auth = (
        "ahmin",  # kid
        "real-key",  # d
        "real-key",  # x
        "real-key")  # y
    with Sender(host, port, auth=auth, tls=True) as sender:
        # Record with provided designated timestamp (using the 'at' param)
        # Notice the designated timestamp is expected in Nanoseconds,
        # but timestamps in other columns are expected in Microseconds.
        # The API provides convenient functions
        sender.row(
            'trades',
            symbols={
                'pair': 'USDGBP',
                'type': 'buy'},
            columns={
                'traded_price': 0.83,
                'limit_price': 0.84,
                'qty': 100,
                'traded_ts': datetime.datetime(
                    2022, 8, 6, 7, 35, 23, 189062,
                    tzinfo=datetime.timezone.utc)},
            at=TimestampNanos.now())

        sender.flush()

        for i in range(0, 1000):
            # If no 'at' param is passed, the server will use its own timestamp.
            sender.row(
                'trades',
                symbols={'pair': 'EURJPY'},
                columns={
                    'traded_price': 135.97,
                    'qty': 400,
                    'limit_price': None})  # NULL columns can be passed as None,
            # or simply be left out.

            sender.flush()
        print("sent")

if __name__ == '__main__':
    while (True):
        example()

Even though I deliberately changed kid from admin to ahmin the output prints sent, sent ... with no exception.

I see in the server logs

2023-10-05T10:37:05.850164Z I i.q.c.l.t.a.EllipticCurveAuthenticator [101] authentication failed, signature was not verified |  
2023-10-05T10:37:05.822096Z I i.q.c.l.t.a.EllipticCurveAuthenticator [101] authentication read key id [keyId=ahmin]

When I run the Java code example with a malformed key, a java exception is thrown:

    at io.questdb/io.questdb.cutlass.line.tcp.PlainTcpLineChannel.send(PlainTcpLineChannel.java:109)
    at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.writeToUpstreamAndClear(DelegatingTlsChannel.java:409)
    at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.wrapLoop(DelegatingTlsChannel.java:390)
    at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.send(DelegatingTlsChannel.java:183)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.sendAll(AbstractLineSender.java:409)
    at io.questdb/io.questdb.cutlass.line.LineTcpSender.send00(LineTcpSender.java:85)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.put(AbstractLineSender.java:215)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.putUtf8Special(AbstractLineSender.java:255)
    at io.questdb/io.questdb.std.str.CharSink.encodeUtf8(CharSink.java:43)
    at io.questdb/io.questdb.std.str.CharSink.encodeUtf8(CharSink.java:35)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.tag(AbstractLineSender.java:296)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.symbol(AbstractLineSender.java:280)
    at io.questdb/io.questdb.cutlass.line.AbstractLineSender.symbol(AbstractLineSender.java:38)
    at io.questdb.benchmarks/org.questdb.LineTCPSender03MultiTableMain.doSend(LineTCPSender03MultiTableMain.java:66)
    at io.questdb.benchmarks/org.questdb.LineTCPSender03MultiTableMain.lambda$main$0(LineTCPSender03MultiTableMain.java:44)
    at java.base/java.lang.Thread.run(Thread.java:829)
    Suppressed: io.questdb.cutlass.line.LineSenderException: [32] send error 
        at io.questdb/io.questdb.cutlass.line.tcp.PlainTcpLineChannel.send(PlainTcpLineChannel.java:109)
        at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.writeToUpstreamAndClear(DelegatingTlsChannel.java:409)
        at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.wrapLoop(DelegatingTlsChannel.java:390)
        at io.questdb/io.questdb.cutlass.line.tcp.DelegatingTlsChannel.send(DelegatingTlsChannel.java:183)
        at io.questdb/io.questdb.cutlass.line.AbstractLineSender.sendAll(AbstractLineSender.java:409)
        at io.questdb/io.questdb.cutlass.line.LineTcpSender.flush(LineTcpSender.java:80)
        at io.questdb/io.questdb.cutlass.line.AbstractLineSender.close(AbstractLineSender.java:121)
        at io.questdb.benchmarks/org.questdb.LineTCPSender03MultiTableMain.doSend(LineTCPSender03MultiTableMain.java:57)
        ... 2 more
amunra commented 9 months ago

Closed, no-op.

See description in linked issue.