Hello all, I am trying to use the Typesense python...
# community-help
t
Hello all, I am trying to use the Typesense python client to talk to my typesense server hosted on EKS. I am using kubectl to port-forward one of the eks nodes to my localhost. The server is working properly, as I am able communicate with the server using the supplied postman collection without any issues… but when I try from inside a locally hosted django app, it fails.
Copy code
ipdb> ts_client.collections.retrieve()
*** requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8108): Max retries exceeded with url: /collections (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff2596ae950>: Failed to establish a new connection: [Errno 111] Connection refused'))
I am initializing my client,like so:
Copy code
ts_client = typesense.Client({
    'api_key': 'redacted-for-slack',
    'nodes': [{
        #'host': 'ts.typesense.svc.cluster.local',
        'host': 'localhost',
        'port': '8108',
        'protocol': 'http'
    }],
    'connection_timeout_seconds': 5
})
… if anyone were to have any thoughts, suggestions, or advice I would appreciate it. Thanks!
I suspect this could have something to do with the csrf token… but I am not sure, as I have updated my python code to use the requests library and I get the same error. ---- The investigation continues…
m
cc @Jason Bosco would appreciate any help on this 🙏
j
@Travis Payne / @madhweep lakshmanan
"but when I try from inside a locally hosted django app"
Is this app running in a docker container by any chance?
t
It is
And I just had a success, from a non-dockerized
requests.get
call that fails from inside the dockerized app.
j
Ah ok, so what's happening is that "localhost:8108" within the docker container refers to port 8108 within that container. Whereas your TS server is running outside of Docker's internal network
t
Well that does explain it… I need to map my localhost port to the docker container.
j
Yup
t
🙏, many thanks sir.
👍 1
m
thank you Jason!
j
Happy to help!