-
Notifications
You must be signed in to change notification settings - Fork 26
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
Getting started instructions aren't working (for me) #92
Comments
After some digging around in the Rust sources, I was able to find the secret to providing a host connection to the sensor and subscriber python scripts. I'm pretty sure there's a simpler solution, but posting here in case anyone else hits the same thing and just wants to get something working that they can mess around with: z_subscriber.pyimport zenoh, time
TOPIC = 'myhome/kitchen/temp'
CONNECT_EPS = '{"endpoints": ["tcp/127.0.0.1:7447"]}'
def listener(sample):
print(f"Received {sample.kind} ('{sample.key_expr}': '{sample.payload.to_string()}')")
if __name__ == "__main__":
config = zenoh.Config()
config.insert_json5("connect", CONNECT_EPS) # Use the IP from the logs
session = zenoh.open(config)
sub = session.declare_subscriber(TOPIC, listener)
print("Waiting for inbound data...") z_sensor.pyimport zenoh, random, time
random.seed()
TOPIC = 'myhome/kitchen/temp'
CONNECT_EPS = '{"endpoints": ["tcp/127.0.0.1:7447"]}'
def read_temp():
return random.randint(15, 30)
if __name__ == "__main__":
config = zenoh.Config()
config.insert_json5("connect", CONNECT_EPS) # Use the IP from the logs
session = zenoh.open(config)
pub = session.declare_publisher(TOPIC)
while True:
t = read_temp()
buf = f"{t}"
print(f"Putting Data ('{TOPIC}': '{buf}')...")
pub.put(buf)
time.sleep(1.0) zeno-myhome.json5{
plugins: {
rest: { // activate and configure the REST plugin
http_port: 8000 // with HTTP server listening on port 8000
},
storage_manager: { // activate and configure the storage_manager plugin
storages: {
myhome: { // configure a "myhome" storage
key_expr: "myhome/**", // which subscribes and replies to query on myhome/**
volume: { // and using the "memory" volume (always present by default)
id: "memory"
}
}
}
}
}
} Commands[shell1] $ zenohd -c zenoh-myhome.json5
[shell2] $ python z_subscriber.py
[shell3] $ python z_sensor.py |
Hi @lukebayes, you don't need the router since it's just a P2P communication. I just confirmed zenoh-python 1.1.1. can normally work without specifying the endpoints. zenoh might fail to discovery the other because the multicast option isn't enabled on your machine. Can you check your network settings? |
Thanks for the quick reply! This is a good place to start looking. I was able to confirm that multicast is enabled on my network interfaces and I can send/receive UDP multicast packets on my loopback and wifi devices, so I don't think there's a firewall problem either. I'll try the examples on a different machine (and network) later today and report back. |
Quick update. I haven't yet been able to test on another machine yet and it might be a few more days until I get another chance. I'll check back before this next weekend is over (EST). Thanks! |
Hi @lukebayes, can you enable the logger by import zenoh, random, time
random.seed()
def read_temp():
return random.randint(15, 30)
if __name__ == "__main__":
zenoh.init_log_from_env_or("info")
with zenoh.open(zenoh.Config()) as session:
key = 'myhome/kitchen/temp'
pub = session.declare_publisher(key)
while True:
t = read_temp()
buf = f"{t}"
print(f"Putting Data ('{key}': '{buf}')...")
pub.put(buf)
time.sleep(1) And run the python file with RUST_LOG=info python3 z_sensor.py |
First off, thanks for putting so much work into what appears to be a critical bit of infrastructure.
I'm probably doing something silly, but thought I'd post an issue here to see if I'm not alone.
I'm on a recently upgraded Ubuntu 24.04 install on a Thinkpad X1 Carbon. FWIW, I also have ROS 2 installed (but not running) on this laptop, so maybe I've got some kind of conflict there.
I'm running Python 3.12.3 (default install with Ubuntu 24.40), but I'm using a local venv for pip modules.
I'm following the instructions posted here
When I run the sensor app, it's like this (looks good to me):
When I run the subscriber app, it's just silent. FWIW, it also seems as if the
time.sleep(60)
isn't necessary as yourdeclare_subscriber
function seems to hold the process open.Running
zenohd -c zenoh-myhome.json5
seems to work as expected, but I'd rather not paste the results here as it seems to include a bunch of PII, like my public IP address.Of course I've tried getting help from LLMs but it seems they were trained on outdated APIs.
I've tried to get my pub/sub python apps to talk to a zenohd router, but I can't seem to configure them properly either. I haven't dug too deeply yet, but it's starting to look like maybe the latest packages might be out of date with the docs, so thought I'd post here before wasting too much time.
I'd be happy to submit a PR (once it's working) if that's something you'd like.
Any help or tips appreciated!
The text was updated successfully, but these errors were encountered: