Skip to content

client not using proxy - grpc #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karel-rehor opened this issue Feb 7, 2025 · 1 comment · Fixed by #119
Closed

client not using proxy - grpc #118

karel-rehor opened this issue Feb 7, 2025 · 1 comment · Fixed by #119
Assignees
Labels
bug Something isn't working

Comments

@karel-rehor
Copy link
Contributor

karel-rehor commented Feb 7, 2025

Specifications

  • Client Version: 1.11 dev [unreleased]
  • InfluxDB Version: cloud - [TODO] check also clustered
  • Platform: client ubunt 22.04 + Python 3.12

Using an envoy proxy server between client and server query requests are not showing up in the proxy log. They seem to succeed regardless. This implies that the proxy settings are being ignored. See EAR 5702

Regarding behavior with clustered a related issue is #117

Code sample to reproduce problem

from build.lib.influxdb_client_3 import InfluxDBClient3
import time
import logging
import http.client

def main() -> None:
    print("main()")
    http.client.HTTPConnection.debuglevel = 1
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("request.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True
    client = InfluxDBClient3(
        # host="http://localhost:3000",
        host="https://us-east-1-1.aws.cloud2.influxdata.com",
        token="******",
        org="Bonitoo",
        database="Ephemera",
        proxy="http://localhost:10000",
        # proxy="http://localhost:80",
        debug=True
    )

    now = time.time_ns()

    lp = f'drone,location=harfa,id=A16E22 speed=18.7,alt=97.6,shutter=7 {now}'

    print("Writing Data")
    client.write(lp)
    print(f"Wrote {lp}")

    table = client.query(
        query="SELECT * FROM drone WHERE time >= now() - interval '1 hour'")

    print(table.to_pandas())


if __name__ == "__main__":
    main()

Expected behavior

That the proxy settings be used for both writes and queries. Expect to see in the proxy log a record like the following.

envoy-1  | [2025-02-07T13:10:15.727Z] "CONNECT - HTTP/1.1" 200 DC 418 255 2 - "-" "grpc-httpcli/0.0" "8739665c-96f2-4f8f-9961-5618291c0d24" "192.168.88.82:50051" "192.168.88.82:50051"

Also that proxy settings can be set through environment variables, a configuration file and directly in the client code.

Actual behavior

When inspecting the proxy logs, it appears the write API is using the proxy, however the query API request using Flight > GRPC are not showing up.

Example

envoy-1  | [2025-02-07 09:47:14.922][22][debug][http] [source/common/http/conn_manager_impl.cc:1135] [Tags: "ConnectionId":"11","StreamId":"17761144465323234730"] request headers complete (end_stream=false):
envoy-1  | ':authority', 'us-east-1-1.aws.cloud2.influxdata.com:443'
envoy-1  | ':method', 'CONNECT'
envoy-1  | 
envoy-1  | [2025-02-07 09:47:14.922][22][debug][connection] [./source/common/network/connection_impl.h:98] [Tags: "ConnectionId":"11"] current connecting state: false
envoy-1  | [2025-02-07 09:47:14.922][22][debug][router] [source/common/router/router.cc:525] [Tags: "ConnectionId":"11","StreamId":"17761144465323234730"] cluster 'influxdb_cluster' match for URL ''
envoy-1  | [2025-02-07 09:47:14.922][22][debug][misc] [source/common/upstream/cluster_manager_impl.cc:2295] Allocating TCP conn pool
envoy-1  | [2025-02-07 09:47:14.922][22][debug][router] [source/common/router/router.cc:750] [Tags: "ConnectionId":"11","StreamId":"17761144465323234730"] router decoding headers:
envoy-1  | ':authority', 'us-east-1-1.aws.cloud2.influxdata.com:443'
envoy-1  | ':method', 'CONNECT'
envoy-1  | ':scheme', 'http'
envoy-1  | 'x-forwarded-proto', 'http'
envoy-1  | 'x-request-id', '963c4250-2187-4be5-b7c4-182505b40b06'
envoy-1  | 'x-envoy-expected-rq-timeout-ms', '15000'
...
envoy-1  | [2025-02-07T09:47:14.922Z] "CONNECT - HTTP/1.1" 200 DC 1089 3644 1088 - "-" "-" "963c4250-2187-4be5-b7c4-182505b40b06" "us-east-1-1.aws.cloud2.influxdata.com:443" "34.196.233.7:443"
...

Though the query follows, it does not appear in the log.

Additional info

No response

@karel-rehor karel-rehor added the bug Something isn't working label Feb 7, 2025
@karel-rehor karel-rehor self-assigned this Feb 7, 2025
@karel-rehor karel-rehor changed the title client not working using proxy - grpc client not using proxy - grpc Feb 7, 2025
@karel-rehor
Copy link
Contributor Author

karel-rehor commented Feb 7, 2025

Note that when ENVAR grpc_proxy is set, the proxy server is called.

e.g. Client call from IDE with the following ENVARS

PYTHONUNBUFFERED=1;grpc_proxy=http://localhost:10000

Then in proxy console log...

envoy-1  | [2025-02-07T14:13:18.933Z] "CONNECT - HTTP/1.1" 200 DC 1089 3644 1048 - "-" "-" "cff42e10-77ea-4031-8945-fe30744ad97f" "us-east-1-1.aws.cloud2.influxdata.com:443" "34.196.233.7:443"
envoy-1  | [2025-02-07T14:13:19.282Z] "CONNECT - HTTP/1.1" 200 DC 1214 7321 700 - "-" "grpc-httpcli/0.0" "7f421443-2c9a-42e0-aa4c-031334444ce2" "us-east-1-1.aws.cloud2.influxdata.com:443" "34.196.233.7:443"

And results are correct...

    alt      id location  shutter  speed                          time
0  97.6  A16E22    harfa      7.0   18.7 2025-02-07 14:13:18.930199607
1  97.6  A16E22    harfa      7.0   18.7 2025-02-07 14:00:48.277472412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant