I'm following the chat app tutorial in the async book and I have a question. If I wanted to deploy the chat server to a service like Heroku, what would I use instead of "127.0.0.1:8080"
on this line:
fn run() -> Result<()> {
task::block_on(accept_loop("127.0.0.1:8080"))
}
I built this server and deployed to Heroku with the following code, and I believe it is working:
let port = std::env::var("PORT").unwrap();
println!("Listening on port {}", port);
task::block_on(accept_loop(format!("0.0.0.0:{}", port)))
When I check the logs, it appears to be running on that port but I wanted to ask if this was the correct way to code it.
Second, I can't get the client working. For the client app, the tutorial shows:
fn run() -> Result<()> {
task::block_on(try_run("127.0.0.1:8080"))
}
but I have no idea what to put in place of that IP address. Since I'm printing the port to the server console, I can get the port number and I can also look up the IP address associated with the Heroku URL but when I tried that I get an error message that says:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Does anyone know what the client connection code should look like?