Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 13:32
    autodidaddict commented #428
  • 12:42
    pickfire commented #1670
  • 11:26
    autodidaddict commented #428
  • 07:54
    fakeshadow commented #1670
  • 07:36
    pickfire commented #1670
  • 07:35
    pickfire commented #1670
  • 07:12
    Neopallium commented #428
  • 05:38
    fakeshadow commented #1670
  • 03:59
    fakeshadow commented #1692
  • Sep 26 23:58
    codecov-commenter commented #1712
  • Sep 26 23:45
    codecov-commenter commented #1712
  • Sep 26 23:26
    PeterUlb edited #1712
  • Sep 26 23:23
    PeterUlb synchronize #1712
  • Sep 26 23:21
    robjtede edited #1712
  • Sep 26 23:15
    PeterUlb opened #1712
  • Sep 26 21:51
    robjtede commented #1710
  • Sep 26 21:32
    robjtede commented #1710
  • Sep 26 20:45
    Shnatsel commented #1296
  • Sep 26 20:43
    robjtede commented #1710
  • Sep 26 18:52
    robjtede labeled #1462
Is there an easy way to get my logger middleware to show request and response bodies?
Or a hard way I suppose, but... no harder than just writing logging into my handlers...
3 replies
Simon Paitrault


I'm trying to build an app where I've an API (with actix-web) and another domain runtime (with actix actors) that deal with database and other stuff. I was wondering what was the best way to communicate between those two entities and if there is some example around that kind of project?

8 replies
tml hi, is there any benefit to the sync actor ("executor") pattern, as in the old version of the docs over just using web::block as in the new docs?
1 reply

tml > <> @tml if you're expecting to use other actors i guess. web::block has been the recommended method for DB calls since v2 and the docs now reflec that.

Hm, is web::block incompatible with actors?


tml > <> Hm, is web::block incompatible with actors?

As in, can I call web::block inside of actors and vice-versa?


robjtede > <> As in, can I call web::block inside of actors and vice-versa?

Sure you can do that but theres kinda no point doing both and just requires more passing around of channel senders.

Bernard Labno

I've got

#[derive(Message, Debug)]
#[rtype(result = "Vec<String>")]
pub struct GetItems;

impl Handler<GetItems> for SomeActor {
    type Result = Vec<String>;

    fn handle(&mut self, msg: GetItems, _ctx: &mut Self::Context) -> Self::Result {
        println!("Got {:?}", msg);

which gives me

the trait bound Vec<std::string::String>: MessageResponse<SomeActor, GetItems> is not satisfied.

I've seen example where Result type was Result<Vec<String>> but I don't get why that works.

13 replies
This message was deleted
Kevin Choubacha
Hi! I'm trying to setup an actix-web server but also want to daemonize the main process. I have it set up using the daemonize crate ( but I'm getting some errors when the server actually boots:
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Int err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Hup err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Term err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Quit err: Bad file descriptor (os error 9)
Kevin Choubacha
I think I need to daemonize before the actix-rt starts so that the daemonizing doesn't close any file descriptor listeners... But I can't find examples of setting that up.
Kevin Choubacha
Nothing I've tried works to properly boot the runtime other than the macro...
Alan Briolat
Am I crazy if I want to use actix directly as an actor framework? I'm really struggling to understand the boundary between async/await and message-passing. Examples make use of addr.send().await inside an async fn main(), but are less clear on how to do the same thing within a Handler<T>::handle(), which isn't an async fn...
Alan Briolat
For example, I have an actor that needs to establish a TCP connection once the actor is already started. The documentation for actix::actors::resolver only shows use from async functions outside of an actor, so what pattern should I be using to use that from within a message handler?
19 replies
I can't find anywhere in the Actix-Cors documentation on how to allow Access-Control-Allow-Origin so I can allow GET/POST requests to my Rust-code from other domains.
1 reply
Maybe you already know this, but the Actix benchmarks are gone from TechEmpower.
12 replies
Why does encourage using Diesel instead of async_pg?
2 replies
Paul Kassianik
Hey guys, wondering if there's any documentation to handle file uploads in Post requests?
2 replies
How do I get current tokio/actix-rt loop inside HttpServer::new(move || App::new()?
3 replies
For each worker
I need to do some async actions while creating .data
Alan Briolat
Is there an upperbound on what a sensible number of actors is, either in terms of performance or just "you're doing it wrong"?
10 replies
Alan Briolat
I'm playing around with trying to build a BitTorrent client, which is obviously a pretty IO-bound use case. My thoughts so far are that the logical division of responsibilities, and therefore actors, is a single Session actor (which is the entry point for the frontend communicating with the core), a Torrent actor per loaded torrent (potentially thousands), a Peer actor per known peer (tens of thousands, only a few hundred of which would have active connections at any one time), and some mechanism to globally limit simultaneous connection count and file handle count.
Does this sound sensible, or like I should be considering pooling things into fewer actors, or not even using the actor model at all?
Hi all, as a Rust Newbie, i tried to build a web site with actix-web. I wanted to process default url to index.html. So i decided to write a middleware to do the job. To modify the Request uri, i followed what was done in Normalize middleware but it looks to me a lot of code to change the path of the request, isn't there any simpler way to do this?
2 replies
Kevin Hoffman
I'm sure this has been asked a million times... I've got a synchronous function (mandatory, it's an FFI callback) that needs to make a call into the actor system, await the result, and then return the result. I've tried all forms of "block_on" that I can think of and none of them work. What's the right way to "de-async" a call to an actor?
3 replies
Bernard Labno
expected struct Box, found struct Pin
Bernard Labno
I've noticed that for ResponseFuture the Box::pin works, but for ResponseActFuture the Box::new is needed instead
17 replies
Bernard Labno
btw. I am looking for someone to review ~1k lines of my actix code, I'm willing to pay for the job.
Bernard Labno
Is it possible to convert ActorFuture to Future?
7 replies
Brian Victor
are there any reasonably mature solutions for (customer) authentication and identity management? basically looking to fill the role that django auth does, with login/registration/password reset/etc. should I be looking at something like AWS Cognito with OIDC?
Cris Liao
SSE long-polling connection server using Actix-web 3.0.2, while the clients use Java & okhttp lib, the server can support concurrent connections more than 400K; but when the clients use C++ & libcurl, when concurrent connections add up to 130K, the server will hangs on and logging:
"Service is unavailable"
Accepting connections on has been resumed
Anybody knows where the problem is?

Hi guys, I have this struct (diesel):

#[table_name = "users"]
#[derive(Insertable, Debug)]
pub struct NewUser<'a> {
    pub first_name: &'a str,
    pub last_name: &'a str,

let m = NewUser {
    first_name: "Foo",
    last_name: "Bar",

But am wondering why, I can do this:

let user: User = diesel::insert_into(...).values(&m).get_result(conn).expect(...);

But not this:

impl<'a> NewUser<'a> {
    pub fn create( & self, conn: &PgConnection) -> self::User {

1 reply
Hi guys, is there any comprehensive example of actix-net? I'm quite new for the rust and seeking help to use actix-net framework to build my tcp server. TIA.
6 replies
Hey, is there any examples/projects which use Auth0 for authentication?
1 reply
hi, how do i extract data from web::data pool ?
1 reply
How can I pass data from a middleware to a route?
1 reply
Hi, How do I stop an actor with internal loops,sending a message doesn't work.
For example ,I use amiquip with actor, I can't stop it.
        for (_i, message) in consumer.receiver().iter().enumerate() {
            match message {
                ConsumerMessage::Delivery(delivery) => {
                    let msg = delivery.body.clone();
                    let foo = String::from_utf8(msg).unwrap();
                    let data = foo.to_string();
                    let k: Value = serde_json::from_str(&data).unwrap();
                    ctx.stop(); // doesn't work
                other => {
                    println!("Consumer ended: {:?}", other);
Pankaj Jangid

Hi, how can I have resolve like functionality with actix-web? I want to get the server to send the www/build/index.html file if the file requested isn't in www/build. This code doesn't work:

async fn home(_req: HttpRequest) -> io::Result<NamedFile> {

async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
            .service(Files::new("/*", "www/build/"))

The above code just tries to get the file from www/build, but then returns a 404 instead of trying the home service. Is there an easy way I can "chain" these?

Actually nevermind, I'm not sure why I didn't take a look at the API docs. It's pretty clear there;.default_handler(web::route().to(home))) did the job for me
Hey ya'll! I'm using actix-web = "3" and actix-multipart = "0.3" and getting some weird behavior trying to upload a file - I can only seem to get the file name out of the payload.

pub async fn test2(
mut payload: Multipart,
) -> Result<String, Error> {

let mut response_details: Vec<String> = vec![];
let mut result = String::from("");

while let Some(item) = {
    let mut field = item?;
    let mut myFileStream: Vec<u8> = vec![];

    // Field in turn is stream of *Bytes* object
    while let Some(chunk) = {
        let mut data = chunk.unwrap().to_vec();
        myFileStream.append(&mut data);

        format!("{:?}", myFileStream)


myFileStream ends up only containing the name of the source file from the client.
49 replies
Hi. I'm using actix-web 3 and actix-web-actors 3 and I have questions about websockets that both reply to incoming messages and pull from (for example) an AMQP queue. I'm trying to figure out what pattern works for this. I'm guessing it needs to be something like using ws::start_with_addr and passing the addr to a thread::spawn with an infinite loop that keeps sending to the WS actor until it gets an error. I don't see another clear way to do this. Anyone have suggestions?
16 replies