Skip to content
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

PDF preview of LaTeX Workshop (code-server) results in HTTP 400: Bad Request #445

Closed
benz0li opened this issue Feb 13, 2024 · 4 comments · Fixed by #458
Closed

PDF preview of LaTeX Workshop (code-server) results in HTTP 400: Bad Request #445

benz0li opened this issue Feb 13, 2024 · 4 comments · Fixed by #458
Labels

Comments

@benz0li
Copy link

benz0li commented Feb 13, 2024

Bug description

code-server: coder/code-server#6667

JupyterLab:

[I 2024-02-13 15:50:09.573 ServerApp] Trying to establish websocket connection to ws://localhost:56227/proxy/39607/
[E 2024-02-13 15:50:09.579 ServerApp] Uncaught exception GET /code-server/proxy/39607/ (192.168.65.1)
    HTTPServerRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/code-server/proxy/39607/', version='HTTP/1.1', remote_ip='192.168.65.1')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/site-packages/tornado/websocket.py", line 940, in _accept_connection
        await open_result
      File "/usr/local/lib/python3.11/site-packages/jupyter_server_proxy/handlers.py", line 853, in open
        return await super().open(path)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyter_server_proxy/handlers.py", line 678, in open
        return await super().open(self.port, path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyter_server_proxy/handlers.py", line 557, in open
        return await self.proxy_open("localhost", port, proxied_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jupyter_server_proxy/handlers.py", line 505, in proxy_open
        await start_websocket_connection()
      File "/usr/local/lib/python3.11/site-packages/jupyter_server_proxy/handlers.py", line 492, in start_websocket_connection
        self.ws = await pingable_ws_connect(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
    tornado.httpclient.HTTPClientError: HTTP 400: Bad Request

How to reproduce

  1. [Terminal] Command docker run -it --rm -p 8888:8888 -p 47395:47395 glcr.b-data.ch/jupyterlab/r/verse:latest-devtools
  2. [Browser] Open http://127.0.0.1:8888/lab?token=[redacted]
  3. [JupyterLab] Click on 'code-server [↗]'
  4. [code-server] When asked 'Do you trust the authors of the files in this folder?'
    • Click on 'Yes, I trust the authors'
  5. [code-server] Explorer > Right click > New File...: sample.tex
    • Use sample from Code sample
  6. [code-server] View > Command Palette... (F1): LaTeX Workshop: Build LaTeX project
  7. [code-server] View > Command Palette... (F1): LaTeX Workshop: View LaTeX PDF file in VSCode tab
  8. [code-server] File sample.tex: Change \date{2024-02-09} to \date{2024-02-13}

Expected behaviour

The LaTeX PDF file in VSCode tab updates accordingly.

Actual behaviour

The LaTeX PDF file in VSCode tab does not update.

Code sample

Sample $\TeX$ file:

\documentclass{article}

\title{My first document}
\date{2024-02-09}
\author{John Doe}

\begin{document}
  \maketitle
  \newpage

  Hello World!

\end{document}

Your personal set up

  • OS:
    • Host: macOS 14.3.1 (Sonoma)
    • Container: Debian 12 (bullseye)
  • Version(s):
    • JupyterHub: 4.0.2
    • JupyterLab: 4.1.0
    • Jupyter Server Proxy: 4.1.0
    • code-server: 4.21.1 (Code 1.86.1)
    • LaTeX Workshop: 9.18.0
Full environment

Container:

aiohttp==3.9.3
aiosignal==1.3.1
alembic==1.13.1
anyio==4.2.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
astroid==3.0.3
asttokens==2.4.1
async-generator==1.10
async-lru==2.0.4
attrs==23.2.0
autopep8==2.0.4
Babel==2.14.0
beautifulsoup4==4.12.3
bleach==6.1.0
certifi==2024.2.2
certipy==0.1.3
cffi==1.16.0
charset-normalizer==3.3.2
colorama==0.4.6
comm==0.2.1
cryptography==42.0.2
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.8
docstring-to-markdown==0.13
executing==2.0.1
fastjsonschema==2.19.1
flake8==7.0.0
fqdn==1.5.1
frozenlist==1.4.1
gitdb==4.0.11
GitPython==3.1.41
greenlet==3.0.3
h11==0.14.0
httpcore==1.0.2
httpx==0.26.0
idna==3.6
importlib-metadata==7.0.1
ipykernel==6.29.2
ipython==8.21.0
ipython-genutils==0.2.0
isoduration==20.11.0
isort==5.13.2
jedi==0.19.1
Jinja2==3.1.3
json5==0.9.14
jsonpointer==2.4
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jupyter-events==0.9.0
jupyter-lsp==2.2.2
jupyter-server-mathjax==0.2.6
jupyter-telemetry==0.1.0
jupyter_client==8.6.0
jupyter_core==5.7.1
jupyter_server==2.12.5
jupyter_server_proxy==4.1.0
jupyter_server_terminals==0.5.2
jupyterhub==4.0.2
jupyterlab==4.1.0
jupyterlab-lsp==5.0.3
jupyterlab_git==0.50.0
jupyterlab_pygments==0.3.0
jupyterlab_server==2.25.2
Mako==1.3.2
MarkupSafe==2.1.5
matplotlib-inline==0.1.6
mccabe==0.7.0
mistune==3.0.2
multidict==6.0.5
nbclassic==1.0.0
nbclient==0.9.0
nbconvert==7.16.0
nbdime==4.0.1
nbformat==5.9.2
nest-asyncio==1.6.0
notebook==7.0.7
notebook_shim==0.2.3
oauthlib==3.2.2
overrides==7.7.0
packaging==23.2
pamela==1.1.0
pandocfilters==1.5.1
parso==0.8.3
pexpect==4.9.0
platformdirs==4.2.0
pluggy==1.4.0
prometheus-client==0.19.0
prompt-toolkit==3.0.43
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pycodestyle==2.11.1
pycparser==2.21
pydocstyle==6.3.0
pyflakes==3.2.0
Pygments==2.17.2
pylint==3.0.3
pyOpenSSL==24.0.0
python-dateutil==2.8.2
python-json-logger==2.0.7
python-lsp-jsonrpc==1.1.2
python-lsp-server==1.10.0
pytoolconfig==1.3.1
PyYAML==6.0.1
pyzmq==25.1.2
radian==0.6.12
rchitect==0.4.6
referencing==0.33.0
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rope==1.12.0
rpds-py==0.17.1
ruamel.yaml==0.18.6
ruamel.yaml.clib==0.2.8
Send2Trash==1.8.2
simpervisor==1.0.0
six==1.16.0
smmap==5.0.1
sniffio==1.3.0
snowballstemmer==2.2.0
soupsieve==2.5
SQLAlchemy==2.0.26
stack-data==0.6.3
terminado==0.18.0
tinycss2==1.2.1
tomli==2.0.1
tomlkit==0.12.3
tornado==6.4
traitlets==5.14.1
types-python-dateutil==2.8.19.20240106
typing_extensions==4.9.0
ujson==5.9.0
uri-template==1.3.0
urllib3==2.2.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
whatthepatch==1.0.5
yapf==0.40.2
yarl==1.9.4
zipp==3.17.0
Logs

See Bug description.

@benz0li benz0li added the bug label Feb 13, 2024
@benz0li
Copy link
Author

benz0li commented Feb 13, 2024

The following works, though:

  1. [Terminal] Command docker run -it --rm -p 8888:8888 -p 47395:47395 glcr.b-data.ch/jupyterlab/r/verse:latest-devtools
  2. [Browser] Open http://127.0.0.1:8888/lab?token=[redacted]
  3. [JupyterLab] Terminal: Command code-server --bind-addr 0.0.0.0:47395 --auth none
  4. [Browser] Open http://127.0.0.1:47395/?folder=/home/jovyan/projects
  5. [code-server] When asked 'Do you trust the authors of the files in this folder?'
    • Click on 'Yes, I trust the authors'
  6. [code-server] Explorer > Right click > New File...: sample.tex
    • Use sample from Code sample
  7. [code-server] View > Command Palette... (F1): LaTeX Workshop: Build LaTeX project
  8. [code-server] View > Command Palette... (F1): LaTeX Workshop: View LaTeX PDF file in VSCode tab
  9. [code-server] File sample.tex: Change \date{2024-02-09} to \date{2024-02-13}

@benz0li
Copy link
Author

benz0li commented Feb 13, 2024

#445 (comment) also works over https.
ℹ️ See coder/code-server#6667 (comment)

Furthermore, ShinyApps started in code-server are proxied just fine by jupyter-server-proxy:

[I 2024-02-13 16:35:43.241 ServerApp] Trying to establish websocket connection to ws://localhost:46395/proxy/6048/websocket/
[I 2024-02-13 16:35:43.244 ServerApp] Websocket connection established to ws://localhost:46395/proxy/6048/websocket/

Code sample

Sample ShinyApp

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(
   
   # Application title
   titlePanel("Old Faithful Geyser Data"),
   
   # Sidebar with a slider input for number of bins 
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),
      
      # Show a plot of the generated distribution
      mainPanel(
         plotOutput("distPlot")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
   
   output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
      
      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
}

# Run the application 
shinyApp(ui = ui, server = server)

@benz0li
Copy link
Author

benz0li commented Feb 13, 2024

@consideRatio The culprit seems to be Jupyter Server Proxy.

FYI @bdarnell

@benz0li
Copy link
Author

benz0li commented Feb 13, 2024

@modaresimr Thank you for James-Yu/LaTeX-Workshop#3639.

Maybe you have an idea, why it does not work when code-server is run via Jupyter Server Proxy.

P.S.: I have also whitelisted your GitHub account at https://coder.jupyter.b-data.ch if you want to take a look at this specific setup1.

Footnotes

  1. Traefik: TLS termination, proxy no. 1; JupyterHub: proxy no. 2; JupyterLab: proxy no. 3 (Jupyter Server Proxy); code-server: web app (proxy no. 4)

benz0li added a commit to benz0li/jupyter-server-proxy that referenced this issue Feb 15, 2024
benz0li added a commit to benz0li/jupyter-server-proxy that referenced this issue Feb 16, 2024
@benz0li benz0li reopened this Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-julia-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-python-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-r-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-julia-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-python-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-r-docker-stack that referenced this issue Feb 17, 2024
benz0li added a commit to b-data/jupyterlab-julia-docker-stack that referenced this issue Feb 18, 2024
benz0li added a commit to b-data/jupyterlab-python-docker-stack that referenced this issue Feb 18, 2024
benz0li added a commit to b-data/jupyterlab-r-docker-stack that referenced this issue Feb 18, 2024
benz0li added a commit to benz0li/jupyter-server-proxy that referenced this issue Feb 18, 2024
- Modify tests to use headers
- Remove SubprotocolWebSocket
- Add test for empty and no subprotocols
- Fix jupyterhub#442
- Fix jupyterhub#445
benz0li added a commit to b-data/jupyterlab-qgis-docker-stack that referenced this issue Feb 18, 2024
benz0li added a commit to b-data/jupyterlab-qgis-docker-stack that referenced this issue Feb 18, 2024
consideRatio pushed a commit to consideRatio/jupyter-server-proxy that referenced this issue Feb 21, 2024
- Modify tests to use headers
- Remove SubprotocolWebSocket
- Add test for empty and no subprotocols
- Fix jupyterhub#442
- Fix jupyterhub#445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment