-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker / serve / WebSocket connection to 'ws://0.0.0.0:3000/__livereload' failed: bad URL #1698
Comments
Could it be a solution to replace Lines 224 to 236 in a72d600
|
I'm looking into this issue. I've made some changes to my branch(PR #1771) : const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
const socket = new WebSocket(wsAddress); WebSocket of livereload now uses host and port of the current page, and it works with HTTPS site. I'v started mdbook inside a Docker container on my Linux server, which can be accessed at https://mdbook-1698.issue.fuyongxing.com, using the following Dockerfile: FROM rust
WORKDIR /app
COPY . /app
WORKDIR /app/code
RUN cargo install --path .
WORKDIR /app
RUN rm -rf code ~/.cargo/git ~/.cargo/registry
CMD ["mdbook","serve" ,"--hostname", "0.0.0.0"] The '__livereload' endpoint is successfully connected: For developers who use a system network proxy: |
In the current version of mdbook, let address = format!("{}:{}", hostname, port);
let livereload_url = format!("ws://{}/{}", address, LIVE_RELOAD_ENDPOINT);
let update_config = |book: &mut MDBook| {
book.config
.set("output.html.livereload-url", &livereload_url)
.expect("livereload-url update failed"); Since the WebSocket could use the host and port of current page, there seems no reason to keep the From my perspective, an |
problem:
The web socket connection fails if the IP of the website is not equal to the IP used to start
mdbook serve
which is different when started in a docker container.setup:
The problem is, that mdbook server has to listen on all external ports in the container:
mdbook server --hostname '0.0.0.0'
The page preview is viewed under http://127.0.0.1:3000
Dockerfile
docker-compose.yml
The text was updated successfully, but these errors were encountered: