Questions tagged [rust-actix]

Actix is a rust library built on the Actor Model which allows applications to be written as a group of independently executing but cooperating "Actors" which communicate via messages.

Actix (source code) is a Rust actors framework.

233 questions
0
votes
0 answers

Problem with handling async inside of an actix-rust actor

Currently I'm checking out Actix, a Rust based actor framework. I'm also using Actix web to build a REST API. Now, I'm familiar with actor based architecture from working with Akka, however, I'm not being able to start a simple async task inside of…
CG-SS
  • 11
  • 4
0
votes
1 answer

Clone crossbeam channel

How do you access a crossbeam channel "send" from every actix-ws callback? This is a version of this asked on a specific example with a beautiful MRE. Specifically, I've made as few changes as possible to the actix-ws example server to keep it neat…
Test
  • 962
  • 9
  • 26
0
votes
1 answer

Send message without request

How do you send a websocket server response (like a json blob) without receiving a message from the client. For example, how would you make an actix webserver that sends a message to a connected client whenever it receives a message from an mpsc?
Test
  • 962
  • 9
  • 26
0
votes
0 answers

actix web actor handle url ws connection

I was wondering if there is a way to create an Actor from actix_web_actor that represents a ws connection from a url. Basically something like this: // Not real code let resp = actix_web_actors::ws::start_from_url(WsActor {},…
0
votes
1 answer

How to send a proper Error response in actix_web middleware?

I develop an authentication middleware for actix_web. I can send an OK response just fine but I cannot send an error message. Here's what I've done so far using the example given here: /// ResponseBody is my own custom struct to send an…
DennyHiu
  • 4,861
  • 8
  • 48
  • 80
0
votes
1 answer

How to define a generic data type as Message in actix

Is there a way to write this code with #[derive(Message)] and #[rtype(result = "...")]. pub struct MyMsg { data: T } impl Message for MyMsg { type Result = Result, Error>; } I tried this but the compiler…
mehdy
  • 3,174
  • 4
  • 23
  • 44
0
votes
2 answers

How to create individual thread for sending pings on client webscoket

I wrote this code, but when sending pings, the program cannot do anything else. How can I spawn another thread to do this work while I do something else in my program? pub fn sending_ping(addr: Addr) -> Result<(), ()> { …
maks vell
  • 1
  • 2
0
votes
0 answers

Unable to serve react app using actix files crate

I am trying to serve a react frontend using actix server with the following service : service(actix_files::Files::new("/app", "./react-front").index_file("./react-front/index.html") And I have the following structure in react-front which is a react…
RequireKeys
  • 466
  • 4
  • 15
0
votes
0 answers

Actix Websocket : how to handle JSON message from client?

I'm making a small fighting game with Actix Web and Actix WebSocket. My client sends a JSON that contains attack data, and I'm wondering how to serialize the JSON into the corresponding Rust struct. It seems that StreamHandler does not allow to…
Ershetz
  • 35
  • 4
0
votes
1 answer

How to add ACCESS_CONTROL_ALLOW_ORIGIN header in actix-web server?

Im trying to add a header to allow my API to be called from anywhere. I try to use this (https://docs.rs/actix-web/latest/actix_web/http/header/constant.ACCESS_CONTROL_ALLOW_ORIGIN.html) with value * as the response header I need that header for…
DennyHiu
  • 4,861
  • 8
  • 48
  • 80
0
votes
1 answer

How can I build and run my Actix application using cargo in docker?

Second part of my question: Is it wise to do that to start my application? Or you think it's better to build the app on my local machine and then use the binary file in docker? Is build release final file work on PaaS docker as well as on my windows…
AmyyazdaN
  • 303
  • 1
  • 9
0
votes
0 answers

Rollback integration test

I'm currently trying to create a simple integration test that for example try the signup endpoint. Coming from many other backend languages I'm used to rollback database after each test. How can I do this using sqlx? Is there any way to start sqlx…
mcfly
  • 774
  • 1
  • 8
  • 18
0
votes
0 answers

Propagate different errors when the function output is fixed by a macro

I'm new to rust, and facing an error when propagating different error types (from actix and sqlx in this case). I saw that similar problems are addressed by changing the return of the function to the appropriate type, or to an enum of the different…
Marc Garcia
  • 3,287
  • 2
  • 28
  • 37
0
votes
1 answer

Write behind async tasks

In a web environment with Actix-Web I want to write behind data to a database, async so the request is not held up. This could also be calling a webhook or calling an API to send an email. With Scala I would create a queue and use a thread pool…
KingOfCoders
  • 2,253
  • 2
  • 23
  • 34
0
votes
1 answer

How can I get the response status in actix-web middleware?

I am using actix-web 3. I would like to access the current status code from within Actix-web’s middleware system. I would like to modify the request based on the StatusCode, is this possible? For instance if the user sends some data that causes…
Allan K
  • 379
  • 2
  • 13