Closed drbh closed 5 years ago
forgot to add the rust Publisher
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
let context = zmq::Context::new();
let publisher = context.socket(zmq::PUB).unwrap();
publisher
.bind("tcp://127.0.0.1:5555")
.expect("failed binding publisher");
loop {
let start = SystemTime::now();
let since_the_epoch = start
.duration_since(UNIX_EPOCH)
.expect("Time went backwards");
let s = format!("{:?}", since_the_epoch);
publisher
.send(&s, 0)
.expect("failed sending first envelope");
let mut child = Command::new("sleep").arg(".5").spawn().unwrap();
let _result = child.wait().unwrap();
}
}
You are ignoring all errors. Check the errors, perhaps they give a clue.
Are Go en Rust using the same version of ZeroMQ? Both version 3, or both version 4?
The Rust example doesn't compile. I get:
error[E0433]: failed to resolve. Use of undeclared type or module `zmq`
I should show the errors - I'll do some digging!
In order to compile the rust code you'll need to include zmq
in the cargo.toml file. I've uploaded a repo with the working code here: https://github.com/drbh/gorustzmq
You should be able to run the Rust publisher and all the clients using the provided code.
I added error outputs to the Go code - but they both retun nil
...
I seem to be using zmq 4.3.1
in all cases....
update!!!
I've changed
subscriber.Connect("tcp://*:5555")
to
subscriber.Connect("tcp://localhost:5555")
and it worked! guess *: isnt allowed in zqm4.
The updated code is in: https://github.com/drbh/gorustzmq
Thanks for the responses @pebbe
Hey ZQM4'ers,
I am having issues integrating Go + ZQM with my existing ecosystem... My Go ZMQ subscriber does not receive any messages!
I currently have a Rust publisher that emits data (a timestamp) every half second.
Clients in Python, Go and Node need to subscribe and act on the data. Both my Python and Node clients have no issues subscribing to the messages.
The Working Clients
Python Client
Node Client
The Not Working Client
When I start the Go client - no messages are received.
My go client..
Am I doing something incorrect? Should I not expect zmq4 to work with my Rust publishers? Am I subscribing to the wrong topic (with the empty string?) The go sub works when I use a go pub - but not outside of the lang...
Thanks!