Closed bbigras- closed 6 years ago
ldap3 library starts its own tokio-core reactor. you should start it in separate thread outside of actix
re-open if you have more info
Probably related: https://github.com/tokio-rs/tokio-core/issues/319
re-open if you have more info
I met the same problem...I want to use actix_web as my web framework , and capnp as the rpc framework,bug when I call the rpc service in the actix.It panic with error message 'cannot recursively call into Core
'.I know it may not a bug of actix...bug I am really a noob with rust and tokio framework,and I need some help .
my router (with actix-web-async-await)
App::new()
.middleware(Logger::default())
.resource("/greet/{name}", |r| {
r.method(Method::GET).with_async(compat(handler::test))
})
my handler(in my handler , I want to get the result from remote rpc server)
pub async fn test(name: Path<String>) -> Result<impl Responder, Error> {
let mut core = Core::new().unwrap();
let handle = core.handle();
let addr = RPC_ADDRESS
.to_socket_addrs()
.unwrap()
.next()
.expect("could not parse address");
let stream = core.run(TcpStream::connect(&addr, &handle)).unwrap();
stream.set_nodelay(true).unwrap();
let (reader, writer) = stream.split();
let rpc_network = Box::new(twoparty::VatNetwork::new(
reader,
writer,
rpc_twoparty_capnp::Side::Client,
Default::default(),
));
let mut rpc_system = RpcSystem::new(rpc_network, None);
let greeter_client: greeter::Client = rpc_system.bootstrap(rpc_twoparty_capnp::Side::Server);
handle.spawn(rpc_system.map_err(|e| eprintln!("failed to run the rpc_system client:{:?}", e)));
//build request struct
let mut builder = Builder::new_default();
let mut request = builder.init_root::<HelloRequest::Builder>();
request.set_name(&name);
//set the request param and send the request
let mut quest = greeter_client.say_hello_request();
quest.get().set_request(request.into_reader()).unwrap();
let response = core.run(quest.send().promise).unwrap();
//receive the response
let response = response
.get()
.expect("failed to get response")
.get_response()
.expect("failed to get response content");
let message = response.get_message().expect("failed to get message");
Ok(format!(
"receive a message from {}:{}",
RPC_ADDRESS, message
))
}
is here some method for me to solve this problem...
@Lynss Don't do own Core
in your handler, you should learn more how to work async ecosystem and how to chain futures
I just updated actix-web from 0.3.3 to 0.6.3 and I got this error:
main.rs:125 is an await!() from futures-await.