AuthenticationNeeded Error for Consumer but not for Producer
WuGGu opened this issue · comments
Hi,
maybe I'm a total noob and don't see my mistake.
I have a Faktory OSS Intance localy on my machine running. I created a Axum API which adds tasks to the Faktory. It works perfectly.
FAKTORY_URL="tcp://127.0.0.1:7419"
pub async fn upload_asset_and_enqueue_job(
path: &Path,
eventid: &i128,
sessionid: &i128,
) -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv().ok();
// Retrieve the FAKTORY_URL from environment variables
let faktory_url = env::var("FAKTORY_URL").expect("FAKTORY_URL must be set in .env");
// Convert the path to a string that can be sent to the job server
let path_str = path.to_str().ok_or("Failed to convert path to string")?;
// Connect to Faktory server
let mut p = Producer::connect(Some(&faktory_url))?;
let job_args = JobArgs {
path: path_str.to_string(),
eventid: eventid.clone(),
sessionid: sessionid.clone(),
};
let job_args_json = serde_json::to_string(&job_args)?;
p.enqueue(Job::new("process_csv", vec![job_args_json]))?;
Ok(())
}
Now I want to build a consumer and I used the example code from the docs:
fn main() {
let mut c = ConsumerBuilder::default();
c.register("foobar", |job| -> io::Result<()> {
println!("{:?}", job);
Ok(())
});
let mut c = c.connect(None).unwrap();
if let Err(e) = c.run(&["default"]) {
println!("worker failed: {}", e);
}
}
And I get this error:
thread 'main' panicked at src/main.rs:20:33:
called `Result::unwrap()` on an `Err` value: Connect(AuthenticationNeeded)
I also added tracing and env to play around with the url, but no success.
Maybe I miss something.
My Docker-Compose File:
version: "3.1"
services:
postgres:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: password # This sets the default user's password to 'password'
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data # Persist data
faktory:
image: contribsys/faktory:latest
command: /faktory -b :7419 -w :7420
ports:
- "7419:7419"
- "7420:7420"
volumes:
- faktory-data:/var/lib/faktory
volumes:
postgres-data: # This named volume will store the postgres data
faktory-data: # This named volume will store the faktory data
Ok I setup a complete new project and now at least it works to the localhost Faktory instance. I removed everyting from the old project to look like the new project but still got the bug. I use cargo clean
but nothing helped.
At least it has nothing to do with the library.
So sorry for the issue.