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

REST API always returns empty array #1302

Open
mbspng opened this issue Aug 7, 2024 · 6 comments
Open

REST API always returns empty array #1302

mbspng opened this issue Aug 7, 2024 · 6 comments
Labels
question Further information is requested

Comments

@mbspng
Copy link

mbspng commented Aug 7, 2024

Describe the bug

REST API always returns empty array

To reproduce

Build an run this Docker code

# Use an official Ubuntu as a parent image
FROM ubuntu:20.04 AS builder

# Set environment variables to non-interactive to prevent prompts
ENV DEBIAN_FRONTEND=noninteractive
ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/bin:$PATH

# Install system dependencies
RUN apt-get update && \
    apt-get install -y \
    python3-pip \
    wget \
    git \
    libasio-dev \
    libtinyxml2-dev \
    swig \
    libpython3-dev \
    python3-venv \
    sudo \
    build-essential \
    libssl-dev \
    gcc-10 \
    g++-10 \
    make \
    libssl-dev \
    zlib1g-dev \
    libbz2-dev \
    libreadline-dev \
    libsqlite3-dev \
    curl \
    llvm \
    libncurses5-dev \
    libncursesw5-dev \
    xz-utils \
    tk-dev \
    libffi-dev \
    liblzma-dev && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Install pyenv and set Python version
RUN curl https://pyenv.run | bash && \
    pyenv install 3.10.13 && \
    pyenv global 3.10.13

# RUN wget --no-check-certificate https://download.eclipse.org/zenoh/debian-repo/zenoh-keyring.gpg -O - | apt-key add -
RUN echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /" | tee -a /etc/apt/sources.list > /dev/null
RUN apt-get update && \
    apt-get install -y zenoh

CMD ["zenohd", "--id", "8513e6171ad48733194c2bab57a5dd86"]
docker build -f Dockerfile -t zenoh-test .
docker run -d -p 8000:8000 zenoh-test

Then send curl commands from docs (https://zenoh.io/docs/apis/rest/)

# Put a string value in demo/example/test
curl -X PUT -H "content-type:text/plain" -d 'Hello World!' http://localhost:8000/demo/example/test

Now I expect to see that data when I query it, but I do not:

$ curl -X GET http://localhost:8000/demo/example/test/\*\*
[]%
$ curl -X GET http://localhost:8000/demo/\*\*     
[]%
$ curl -X GET http://localhost:8000/whatever 
[]%    

System info

See docker code.

zenohd v1.0.0-alpha.6 built with rustc 1.75.0 (82e1608df 2023-12-21)

@mbspng mbspng added the bug Something isn't working label Aug 7, 2024
@gabrik
Copy link
Contributor

gabrik commented Aug 7, 2024

Hi @mbspng,

Seems that you are not starting any storage, thus the data published with the PUT is being dropped as no subscriber are present.

Please refer to the reference manual: https://zenoh.io/docs/manual/plugin-storage-manager/#backends-and-volumes

@gabrik gabrik added question Further information is requested and removed bug Something isn't working labels Aug 7, 2024
@mbspng
Copy link
Author

mbspng commented Aug 7, 2024

Hi @mbspng,

Seems that you are not starting any storage, thus the data published with the PUT is being dropped as no subscriber are present.

Please refer to the reference manual: https://zenoh.io/docs/manual/plugin-storage-manager/#backends-and-volumes

@gabrik Even when I start it with a storage, the outcome is the same. I followed the example in https://zenoh.io/docs/getting-started/first-app/ even before trying it with Docker. I am running zenohd -c zenoh-myhome.json5 and the storage query script also does not work. The replies() call gives an empty list.

import zenoh

if __name__ == "__main__":
    session = zenoh.open()
    replies = session.get('myhome/kitchen/temp', zenoh.ListCollector())
    for reply in replies():
        try:
            print("Received ('{}': '{}')"
                .format(reply.ok.key_expr, reply.ok.payload.decode("utf-8")))
        except:
            print("Received (ERROR: '{}')"
                .format(reply.err.payload.decode("utf-8")))
session.close()

I added the zenoh-myhome.json5 to my Docker file now and am launching it with CMD ["zenohd", "--id", "8513e6171ad48733194c2bab57a5dd86", "-c", "zenoh-myhome.json"]. The PUT and GET commands from the original post still result in an empty array being returned.

Edit: Ok, got it working, thanks. Documentation could be better, though.

@mbspng mbspng closed this as completed Aug 7, 2024
@mbspng mbspng reopened this Aug 7, 2024
@mbspng
Copy link
Author

mbspng commented Aug 7, 2024

Actually, I still don't understand why the getting started example does not work. I got the manual PUT and GET working by adjusting the paths to myhome, as per the example config, rather than demo/test. But the retrieval script from the example still is not working.

@gabrik
Copy link
Contributor

gabrik commented Aug 8, 2024

Hi @mbspng, thank you for spotting this, the documentation is not yet updated to the 1.0.0-alpha.X.
We are going to update it once the final 1.0.0 is released

@mbspng
Copy link
Author

mbspng commented Aug 8, 2024

@gabrik Ok thanks, installing zenoh=0.11.0-stable made it work. Documentation should state which version it is for, and apt should maybe not install an alpha version by default. When following the docs (https://zenoh.io/docs/getting-started/installation/) for the installatoin of zenohd, one will get a version of zenohd which does not match the docs!

@anhaabaete
Copy link
Contributor

Hi, if you using Zenohd in a 1.0.0 and using 0.11.0 in a lib to you aplication. It Don't work.
I had this problem here.

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