typst-preview icon indicating copy to clipboard operation
typst-preview copied to clipboard

An option to enable preview via remote server

Open Wsine opened this issue 2 years ago • 7 comments

Describe the bug

I enabled the preview on host 0.0.0.0. However, the client only reads from ws://127.0.0.1:23625/

To Reproduce

./typst-preview --host 0.0.0.0:23627 ./resume.typ

Expected behavior The host and port logic are compatible between server and client

Package/Software version:

typst-preview extension version: v0.7.5

Logs:

typst-preview server log(Output Panel -> typst-preview):

[2023-09-15T06:49:55Z INFO  typst_preview] Arguments: CliArguments {
        font_paths: [],
        root: None,
        data_plane_host: "127.0.0.1:23625",
        control_plane_host: "127.0.0.1:23626",
        static_file_host: "0.0.0.0:23627",
        dont_open_in_browser: false,
        enable_partial_rendering: false,
        input: "./resume.typ",
    }
[2023-09-15T06:49:56Z INFO  typst_preview] Data plane server listening on: 127.0.0.1:23625
[2023-09-15T06:49:56Z INFO  typst_preview] Control plane server listening on: 127.0.0.1:23626
[2023-09-15T06:49:56Z INFO  typst_ts_compiler::service::diag] /resume.typ: compiling ...
[2023-09-15T06:49:56Z INFO  typst_preview] Static file server listening on: 0.0.0.0:23627
[2023-09-15T06:49:56Z INFO  typst_ts_compiler::service::diag] /resume.typ: Compilation succeeded in 42.533155ms
[2023-09-15T06:49:56Z DEBUG typst_preview::actor::typst] TypstActor: waiting for message

typst-preview client log(Help -> Toggle Developer Tools -> Console):

(index):4938 WebSocket Error:  Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
(anonymous) @ (index):4938
error (async)
setupSocket @ (index):4937
(anonymous) @ (index):4899
setTimeout (async)
(anonymous) @ (index):4899
(index):4935 WebSocket connection closed

Additional context Add any other context about the problem here.

Wsine avatar Sep 15 '23 06:09 Wsine

are you using the vscode extension or the binary itself? VSCode remote should work without extra config. (If it doesnt, it's a bug)

Enter-tainer avatar Sep 15 '23 07:09 Enter-tainer

are you using the vscode extension or the binary itself? VSCode remote should work without extra config. (If it doesnt, it's a bug)

I am using the binary itself on the remote server over ssh, and I want to access the result in the browser.

Wsine avatar Sep 15 '23 09:09 Wsine

Could you try the following command? It might be unnecessary to expose preview service to the public network interface (0.0.0.0).

./typst-preview --host 127.0.0.1:23627 ./resume.typ
ssh -CNL 127.0.0.1:23625:127.0.0.1:23625 your-host # for ws service
ssh -CNL 127.0.0.1:23627:127.0.0.1:23627 your-host # for static file server

looks like typst-preview is not ready to customize service's host to this time. It use 127.0.0.1 everywhere.

Myriad-Dreamin avatar Sep 15 '23 12:09 Myriad-Dreamin

We may add even more cli args to specify the port and host the client should connect to 😇 . But that sounds strange to me.

Enter-tainer avatar Sep 15 '23 17:09 Enter-tainer

Similar issue when using typst-preview via coda-server, my local browser tried to access ws://127.0.0.1:{port} (of course it failed) and the preview panel is blank.

xiaoxuan-yu avatar Nov 30 '23 01:11 xiaoxuan-yu

i encourage anyone interested to this to fix it. i also wonder why use typst and this extension in remote: both typst and typst-preview provides builds for all common platforms.

Enter-tainer avatar Nov 30 '23 01:11 Enter-tainer

I think it's very useful and can be used to remotely access the slide

yaohong772 avatar Apr 23 '24 06:04 yaohong772