Is it possible to query a couchbase server running on a forwarded port from a remote server?

75 Views Asked by At

I have a couchbase server running in a remote server. The way I access it is to connect through ssh and tunneling the 8091 port of the remote server to my machine. I can access the couchbase console in the browser, but now I wanted to make request from a python script.

When I run it, I get RequestCanceledException. Any ideas on how to solve this?

from datetime import timedelta

from couchbase.cluster import Cluster
from couchbase.options import ClusterOptions
from couchbase.auth import PasswordAuthenticator
import logging

if __name__ == '__main__':
    # Set your Couchbase cluster credentials and bucket name
    endpoint = "couchbase://localhost:8091"
    username = "<username>"
    password = "<password>"
    bucket_name = "testbucket"

    try:
        # Connect to the cluster
        cluster = Cluster(f"{endpoint}", ClusterOptions(PasswordAuthenticator(username, password)))
        # Wait until the cluster is ready for use.
        cluster.wait_until_ready(timedelta(seconds=5))
        bucket = cluster.bucket(bucket_name)
        # Define the dummy data to send
        data = {
            "type": "airline",
            "id": 1234,
            "callsign": "CBS",

        }

        # Upsert the dummy data to the bucket
        bucket.default_collection().upsert(f"airline_{id}", data)

        cluster.close()
    except Exception as e:
        print(e)

1

There are 1 best solutions below

4
On

Couchbase Server only uses port 8091 for the UI and cluster manager, application access goes through a range of port numbers depending on which services are used. See the list in the docs at https://docs.couchbase.com/server/current/install/install-ports.html