Skip to content
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

[Question]: Issues with Client Development on Windows and Remote Database Connection #1647

Open
joynn opened this issue Aug 14, 2024 · 6 comments
Labels
question Further information is requested

Comments

@joynn
Copy link

joynn commented Aug 14, 2024

Describe your problem

Hello, I am currently using both the Python API and the HTTP API to connect to a standalone database service. However, it seems that the default connection is only allowed through "localhost." How can I customize the configuration file? I couldn't find any relevant documentation regarding this parameter and its path. Also, is it true that versions of the SDK after 0.2.0.dev7 are only available for Linux and not Windows? How can I develop code on Windows to connect to a 0.3.0.dev4 database? Thank you.

@joynn joynn added the question Further information is requested label Aug 14, 2024
@JinHai-CN
Copy link
Contributor

  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.

  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:

import infinity
infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

@joynn
Copy link
Author

joynn commented Aug 14, 2024

Hello. Actually, for the database server I deployed using Docker, I can successfully access it using "localhost" on the host machine, but not using the real IP. There is no firewall and no network issue. Do I need to modify some config file to enable remote access? But I don't know where the config file is located and how to load it.

@joynn joynn closed this as completed Aug 14, 2024
@joynn joynn reopened this Aug 14, 2024
@JinHai-CN
Copy link
Contributor

(infinity_env) infiniflow@infiniflow:~/infinity_data$ docker run -d --name infinity -v /home/infiniflow/infinity_data/:/var/infinity --ulimit nofile=500000:500000 --network=host infiniflow/infinity:nightly
047a2adaec8a797296b9c7a8c33f9db021fff5cdcf8111354b16a5d02defc8bf
(infinity_env) infiniflow@infiniflow:~/infinity_data$ docker container ls -a
CONTAINER ID   IMAGE                         COMMAND                  CREATED         STATUS         PORTS     NAMES
047a2adaec8a   infiniflow/infinity:nightly   "bash -c 'cp -rf /re…"   6 seconds ago   Up 4 seconds             infinity
(infinity_env) infiniflow@infiniflow:~/infinity_data$ cd ~/Documents/development/infinity
(infinity_env) infiniflow@infiniflow:~/Documents/development/infinity$ python example/simple_example.py 
shape: (3, 3)
┌─────┬─────────────────────────────────┬───────────────────┐
│ num ┆ body                            ┆ vec               │
│ --- ┆ ---                             ┆ ---               │
│ i32 ┆ str                             ┆ list[f64]         │
╞═════╪═════════════════════════════════╪═══════════════════╡
│ 1   ┆ unnecessary and harmful         ┆ [1.0, 1.2, … 0.9] │
│ 2   ┆ Office for Harmful Blooms       ┆ [4.0, 4.2, … 4.5] │
│ 3   ┆ A Bloom filter is a space-effi… ┆ [4.0, 4.2, … 4.5] │
└─────┴─────────────────────────────────┴───────────────────┘

import infinity
from infinity.common import NetworkAddress

try:
    # open a local directory to store the data
    # infinity_instance = infinity.connect("/var/infinity")

    # connect to server with 127.0.0.1
    infinity_instance = infinity.connect(NetworkAddress("192.168.200.127", 23817))

I just tried the latest docker image of as above. Use example/simple_example.py updated with IP address as above code. And it works.

You'd better to check if there are network issue, such as port conflict, incorrect ip address, etc. Use netstat or lsof to check if Infinity is listening on the port.

Infinity installed with deb/rpm can load config file, but docker running infinity can't load config file yet, this problem will be solved in the next Dev release.
infinity -f infinity_conf.toml

@joynn
Copy link
Author

joynn commented Aug 14, 2024

嗯嗯,谢谢大佬

@joynn joynn closed this as completed Aug 14, 2024
@PorYoung
Copy link

PorYoung commented Aug 28, 2024

  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.
  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:
import infinity
infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

Hello, since the HTTP server's listening IP is set to localhost in http_server.cpp, it cannot be accessed from external networks. Does this situation actually exist? Should it be changed to the IP specified in the infinity_conf.toml file?

SharedPtr<HttpConnectionProvider> connection_provider = HttpConnectionProvider::createShared({"localhost", port, WebAddress::IP_4});

By the way, in version 0.3.0-dev7, the provided example of the search API seems incorrect: #874 (comment). Could you provide more examples of the HTTP API, as some of them differ from the SDK API?

if (fusion_json_list.type() != nlohmann::json::value_t::array) {
response["error_code"] = ErrorCode::kInvalidExpression;
response["error_message"] = "Fusion field should be list";
return;

@JinHai-CN
Copy link
Contributor

  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.
  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:
import infinity
infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

Hello, since the HTTP server's listening IP is set to localhost in http_server.cpp, it cannot be accessed from external networks. Does this situation actually exist? Should it be changed to the IP specified in the infinity_conf.toml file?

Yes, it shall be fixed by #1759

SharedPtr<HttpConnectionProvider> connection_provider = HttpConnectionProvider::createShared({"localhost", port, WebAddress::IP_4});

By the way, in version 0.3.0-dev7, the provided example of the search API seems incorrect: #874 (comment). Could you provide more examples of the HTTP API, as some of them differ from the SDK API?

if (fusion_json_list.type() != nlohmann::json::value_t::array) {
response["error_code"] = ErrorCode::kInvalidExpression;
response["error_message"] = "Fusion field should be list";
return;

Yes, we are preparing to release v0.3.0. And the document will be updated accordingly.

JinHai-CN added a commit that referenced this issue Aug 29, 2024
### What problem does this PR solve?

- HTTP server listens on 0.0.0.0 instead of localhost.
- Fix show index issue.

Issue link:#1647, #1757

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: Jin Hai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants