Closed gemtoo closed 1 month ago
Are you using dx serve
? If so, dx
is only meant for development and not hosting an actual app. You'd want something like Nginx or to create a small wrapper server in Rust that serves the app files.
Are you using
dx serve
? If so,dx
is only meant for development and not hosting an actual app. You'd want something like Nginx or to create a small wrapper server in Rust that serves the app files.
Yes I do, the project doesn't compile without dx serve
. Almost like it is intended to run with dx serve
and not otherwise. Lack of documentation on this topic brings me back to the point where I started. I do not give a slightest damn for which purposes dx serve
was intended. It should be able to bind to 0.0.0.0 so that an external host can connect to it. This is the most basic thing your stuff should be able to do and it doesn't.
It is a common issue for users to run their app with dx serve
and in debug
on a released site. I realize that I assumed you were trying to publish your Dioxus app which might not be the case. The information I provided may not have pertained to your specific use case, but it was not intended to dismiss your problem.
The CLI at one point did bind to 0.0.0.0
but must've been removed for whatever reason. The unreleased version on Git supports an --addr
flag for the dx serve
command.
You can build your app with dx build
and optionally in release with --release
for a dist
folder that contains the built app. dx serve
isn't the only option.
Our docs aren't the best and we've already started a full overhaul for the 0.6 release.
Gosh, none of these helped. Fix your shit please. My solution is recursively replace every occurence of 127.0.0.1 with 0.0.0.0 in your repo. You need to understand that not everyone runs Nginx and your app on the same localhost.
Closing this as already implemented and ready for 0.6:
On 0.6 dx serve --addr 0.0.0.0
runs the dx
development server on the 0.0.0.0
ip, allowing external connections.
hi @DogeDark , Thank you for building this amazing crate. The same issue of not being able to bind 0.0.0.0 brought me here, but I think most people understand this is an open source project and they have the patient to wait or the ability to modify the code by themselves.
I tried from fresh Git clone, version 0.6+, your stuff ignores --addr 0.0.0.0
in Docker containers, as well as on the bare metal, anywhere, in Debian, Alpine, Gentoo. I just can't bind it to a custom IP and also it ignores custom port specifications. I even have tried to patch your entire library by recursively replacing all 127.0.0.1 occurrencies with 0.0.0.0 and it still binds to the god damn 127.0.0.1! This is some next level hardcoding.
@gengjun if you really need to get it working ASAP I suggest you running the following process:
socat TCP-LISTEN:9999,reuseaddr,fork TCP:localhost:8080
This process will bind to 0.0.0.0:9999 and proxy all connections to 127.0.0.1:8080 so that you can connect to your app from external source via port 9999.
@gemtoo This is not a good way to use issues:
1) Be polite. If your issue reads as yelling, you shouldn't expect someone to help you for free. I understand it can be frustrating to have issues with your project, but you will get a lot farther with a clear and concise description of the issue than anything else.
2) Add reproductions. This issue could have resolved very quickly if you linked to the project you were having issues with. See https://antfu.me/posts/why-reproductions-are-required
3) Follow the issue template, it is there for a reason. I'm assuming your project is https://github.com/gemtoo/netmath which uses 0.5 and dioxus-fullstack. That information is very useful debugging issues. Fullstack did not respect the --addr
flag in 0.5, but it does in 0.6. In 0.5, you need to call the addr
method on the fullstack config to set the address it is served on
@ealmloff -1. Yeah man I was losing my patience. Not gonna say sorry though. Shit was driving me nuts for a valid reason. At this point I wasn't expecting any help because I've already solved it on my own with a workaround I've provided above.
-3. You're right. It is that project. It uses liveview
though as per Dioxus logs. What you see in git repo is just the tip of an iceberg. Locally I have tried a lot of things in many different ways. Below I have provided reproduction steps with 0.6+. netstat -tulpn
indeed shows that a process binds to 0.0.0.0 and port 12345. That socket though is useless and I am unable to access my app from externally via a custom port, it always returns 500. Guess what? From inside Docker container I am able to access it via http://127.0.0.1:8080
because the app is still bound to hardcoded values. Yes it is bound to both 0.0.0.0:12345 (returns 500) and 127.0.0.1:8080 (real working app) which is infuriating nonsence to me.
-2. Finally, reproduction steps:
2.1. Install Docker + Docker Compose
2.2. Create 2 files in $PWD:
./Dockerfile
FROM rust:1.80-bookworm
RUN apt update && apt upgrade -y && apt install -y subnetcalc net-tools nano libssl-dev gcc pkg-config git socat curl
RUN git clone --depth 1 https://github.com/DioxusLabs/dioxus.git /dx
WORKDIR /dx
RUN cargo install --path ./packages/cli
RUN git clone --depth 1 https://github.com/gemtoo/netmath.git /app
WORKDIR /app
ENTRYPOINT dx serve --addr 0.0.0.0 --port 12345
./docker-compose.yml
services:
netmath:
container_name: netmath
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- 12345:12345
stop_grace_period: 0s
2.3. While in $PWD build and run:
docker compose up -d
2.4. Try to access an app from the browser via its external bound socket.
http://localhost:12345
And see the following error:
Backend connection failed. The backend is likely still starting up. Please try again in a few seconds. Error: Other(
hyper_util::client::legacy::Error(
Connect,
ConnectError(
"tcp connect error",
Os {
code: 111,
kind: ConnectionRefused,
message: "Connection refused",
},
),
),
)
2.5. Proceed into the Docker container as follows:
docker exec -it netmath /bin/bash
Then execute next curl
command:
curl http://localhost:8080
and get a valid response from a working app.
Now that I have provided sufficient information on how to reproduce this behaviour, I am out of this conversation. Despite horrible bugs, Dioxus is still the most promising GUI framework for Rust. Good luck and see ya.
Hi, I need to run a Dioxus app in Docker but it binds to 127.0.0.1:8080. That means it cannot be easily accessed externally. Please allow binding an app to 0.0.0.0. I haven't found anything related to this in documentation, I've read the source code and it seems like 127.0.0.1 is hardcoded which is not the best design choice.