microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 285 forks source link

Cannot connect to remote server by specifying URL #13240

Closed jerrylin96 closed 1 year ago

jerrylin96 commented 1 year ago

Type: Bug

Error message: "A Jupyter Server with this already exists"

It won't let me connect to it (or find it if it already exists). Unclear why this is happening.

Extension version: 2023.3.1000892223 VS Code version: Code 1.77.0 (Universal) (7f329fe6c66b0f86ae1574c2911b681ad5a45d63, 2023-03-29T09:57:11.797Z) OS version: Darwin arm64 22.4.0 Modes: Sandboxed: No Remote OS version: Linux x64 4.18.0-193.28.1.el8_2.x86_64

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 4, 12| |Memory (System)|16.00GB (0.06GB free)| |Process Argv|--crash-reporter-id e2493ef2-63f6-4853-8d76-bd91aaff010d| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: bridges2.psc.edu| |OS|Linux x64 4.18.0-193.28.1.el8_2.x86_64| |CPUs|AMD EPYC 7742 64-Core Processor (256 x 3274)| |Memory (System)|251.59GB (76.65GB free)| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30610679 nodejswelcome1cf:30587006 3biah626:30602489 pyind779:30671433 89544117:30613380 pythonsymbol12:30671437 a9j8j154:30646983 showlangstatbar:30672706 vsccsb:30677849 pythonb192cf:30669361 azdwalk:30687957 pythonms35:30701012 ```
AlexanderPidodnya commented 1 year ago

run in the same problem

sinnpi commented 1 year ago

I'm having the same bug. Jupyter Remote does not currently work properly.

It does work exactly once after reinstalling VSCode using my package manager though.

DonJayamanne commented 1 year ago

@jerrylin96 @AlexanderPidodnya @p-sin I am sorry you are running into this issue Please could you provide the following information

sinnpi commented 1 year ago

@DonJayamanne

  • does the url contain a token

Yes. I'm using Paperspace Gradient.

  • Are you connecting to a Jupyter server without a token and without a password

Yes.

  • Can you share the full url and please feel free to hide parts of the url such as the token

The domain is of the format https://n8ec9z2vnl.clg07azjl.paperspacegradient.com?token=<Token>, where clg07azjl is the ClusterID, and n8ec9z2vnl seems to be the InstanceID.

  • Also after you reload vscode, open a notebook then wait a few minutes, then does the remote Jupyter url appear in the list correctly and are you able to select a kernel from the remote server

I opened VSCode, cleared the list using Jupyter: Clear Jupyter Remote Server List, loaded the remote notebook using Jupyter: Specify Jupyter Server for Connections, Existing Server, entered the url with token.

Now when I try to Select Kernel, it does not show up in the list under Select Another Kernel..., Python Environments. The only other option I have there is to choose Existing Jupyter Server. I enter the URL with token again, and it just jumps back to the Select Another Kernel menu mentioned before.

If I choose Existing Jupyter Server again, it errors with A Jupyter Server with this URL already exists. Python Environments has nothing new, even after waiting for ten minutes.

If I do Jupyter: Specify Jupyter Server for Connections again, the server will appear in the list with the correct Last Connection time, but selecting it does nothing (even though there is a short delay.)

One peculiarity I just noticed: If I do Jupyter: Specify Jupyter Server for Connections > Existing Server, it accepts the server (but doesnt add the remote kernel). If I go Select Kernel (in the notebook) > Select Another Kernel > Existing Server, it gives me the error about the Server already existing. It is weird that these two options that should do the same apparently call different code?

Edit: I just did reload the window and the kernel seems to reliably show up in the list after doing so.

DonJayamanne commented 1 year ago

@jerrylin96 Are you adding the remote Url through the kernel picker or through the command Jupyter: Specify Jupyter Server for Connections

Tibiritabara commented 1 year ago

XPosting from another closed issue

Same issue here. In my scenario I am just trying to launch a local docker container with jupyter and connect the WSL VSCode to the server.

When pressing the button 'Select kernel' and putting the local jupyter URL works for the first time. Then closing VSCode, killing the container, and when launching a new container with Jupyter and trying the same steps once again, it asks for the URL of the remote kernel twice, and the second time it says the same message reported "A Server with this URL already exists".

Additionally, there is a process in the background still trying to connect to the old container that I have not found anyways to cleanup, as it is constantly saying "Forbidden" in the logs (the token was updated with the new container).

To reproduce the issue is simple:

  1. Create a local container with Jupyter:

    FROM python:3.10
    RUN apt update && apt upgrade -y 
    ARG USER
    RUN useradd -ms /bin/bash ${USER}
    USER ${USER}:${USER}
    RUN python3 -m pip install --no-cache-dir --upgrade --user pip
    ENV PATH="$PATH:/home/${USER}/.local/bin"
    WORKDIR /app
    RUN python3 -m pip install --user jupyterlab
    CMD ["jupyter", "lab", "--ip='0.0.0.0'", "--no-browser", "--ServerApp.allow_origin='*'", "--NotebookApp.directory='/app'"] 
  2. Use the select kernel button to connect to the generated url by that container.

  3. Restart the container. It will require a new token

  4. Use the select kernel button again

From there on, the forbidden error is going to be permanently on the logs, and the connection to the remote kernel is permanently damaged. This issue also happens when using Jupyter: Specify Jupyter Server for Connections

jerrylin96 commented 1 year ago

I use Select Kernel -> Select Another Kernel... -> Existing Jupyter Server... -> Enter the URL of the running Jupyter server

denilv commented 1 year ago

I had the same problem - after entering the URL of the existing Jupyter server, it displayed an error message saying 'A Jupyter Server with this already exists' and didn't show up in the 'Existing kernels' section. My solution was to run a container with a Jupyter server in tmux. Then, I entered the URL of the running Jupyter server into VS Code along with the token from tmux. Finally, I restarted the VS Code app, and the existing kernels showed up.

robtelloayala commented 1 year ago

Experiencing the same problem

robtelloayala commented 1 year ago

Whenever I try Select Kernel-> Select Another Kernel...-> Existing Jupyter Server... -> Enter the URL of the running Jupyter server add the url and click enter it asks again for the link and doesn't save it. If you try to add it again it displays A Jupyter Server with this already exists

marcpaga commented 1 year ago

I have found a quick (hopefully temporary) fix for this:

Whenever I try Select Kernel -> Select Another Kernel... -> Existing Jupyter Server... -> Enter the URL of the running Jupyter server add the url and click enter it asks again for the link and doesn't save it. If you try to add it again it displays A Jupyter Server with this already exists

After doing this, one can reload the window: Developer: Reload Window and then re-start the same process. After choosing Existing Jupyter Server, the jupyter server you just added should appear in the list of existing servers. There it can be chosen, and afterwards, you can choose the appropiate kernel.

zthxxx commented 1 year ago

Same problem here after Enter the URL of the running Jupyter server, and Developer: Reload Window works for me now.

zachsiegel-capsida commented 1 year ago

Thank you @DonJayamanne for identifying that #13302 is a duplicate of this issue. Using Developer: Reload Window, then Jupyter: Clear Jupyter Remote Server List, and then finally Jupyter: Specify Jupyter Server for Connections does indeed result in VS Code connecting to my Jupyter kernel.

Any comment on whether/when/how this will be resolved would be greatly appreciated, but for now I am able to open Jupyter notebooks in VS Code, which is a core part of my workflow, so my issue is mostly resolved.

DonJayamanne commented 1 year ago

We will be publishing a fix soon for this. The fix is fairly simple though the workflow is slightly different, instead of using the command Jupyter: Specify Jupyter Server for Connevtions please use the Kernel Picker and enter the Url and select a kernel from there (all in a single, and simpler UI)

DonJayamanne commented 1 year ago

Will fix in the next recovery build (within a day or two)

zachsiegel-capsida commented 1 year ago

Will fix in the next recovery build (within a day or two)

Thank you @DonJayamanne ! Using Jupyter Notebooks in VS Code is a great experience for me.

DonJayamanne commented 1 year ago

The fix has been shipped, please install the latest version of the Jupyter extension

zachsiegel-capsida commented 1 year ago

@DonJayamanne I still experience this issue, but slightly differently now.

Previously, VS Code would not connect to the Jupyter server. Now, VS Code appears to have connected to the server, but when I execute code cells, they do not actually execute. No check mark appears next to the cell, no code executes, and no outputs are generated.

The "Developer: Reload Window" trick previously worked for me. Now, following this update, I am fully unable to use VS Code to connect to my Jupyter server. Really disappointing.

zachsiegel-capsida commented 1 year ago

@DonJayamanne in fact, I cannot use Jupyter in VS Code at all (even with a kernel specified via Python environment).

I use VS Code within "WSL" - all my windows are "Remote: WSL" windows, on a Windows computer. I just opened a native Windows window and was able to use Jupyter in every possible configuration.

So, only the WSL window is failing. I'm not sure why that would be. I exclusively use VS Code with "Remote: WSL" and "Remote: SSH", and I very much hope those environments are fully supported for Jupyter and other extensions.

zachsiegel-capsida commented 1 year ago

My "Jupyter" extension output contains a lot of warnings and errors, both in native Windows VS Code windows (where notebooks are functioning), and in WSL windows (where notebooks are unable to execute code). Here is some of that output:

error 20:34:32.770: Error fetching remote kernels: t [Error]: Forbidden
    at Function.create (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:68133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.t.listRunning (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:55998)
    at jg.getRunningKernels (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:237503)
    at async Promise.all (index 0)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248107) {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://127.0.0.1:8889/api/kernels?1681616072658',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 20:34:32.771: Error fetching remote kernels: t [Error]: Forbidden
    at Function.create (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:68133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.t.listRunning (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:55998)
    at jg.getRunningKernels (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:237503)
    at async Promise.all (index 0)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248107) {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://127.0.0.1:8889/api/kernels?1681616072660',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 20:34:32.771: Error fetching remote kernels: t [Error]: Forbidden
    at Function.create (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:68133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.t.listRunning (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:55998)
    at jg.getRunningKernels (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:237503)
    at async Promise.all (index 0)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248107) {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://127.0.0.1:8889/api/kernels?1681616072661',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 20:34:32.772: Error fetching remote kernels: t [Error]: Forbidden
    at Function.create (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:68133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.t.listRunning (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:55998)
    at jg.getRunningKernels (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:237503)
    at async Promise.all (index 0)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248107) {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://127.0.0.1:8889/api/kernels?1681616072662',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 20:34:32.773: Error fetching remote kernels: t [Error]: Forbidden
    at Function.create (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:68133)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.t.listRunning (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:55998)
    at jg.getRunningKernels (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:237503)
    at async Promise.all (index 0)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248107) {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://127.0.0.1:8889/api/kernels?1681616072663',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
warn 20:34:32.780: Could not fetch kernels from the remote server, falling back to cache: Error: Forbidden
error 20:34:32.780: SessionManager:getKernelSpecs failure:  Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed.
    at e.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:171555)
    at u.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:62984)
    at jg.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:236617)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248904)
warn 20:34:32.781: Could not fetch kernels from the remote server, falling back to cache: Error: Forbidden
error 20:34:32.781: SessionManager:getKernelSpecs failure:  Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed.
    at e.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:171555)
    at u.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:2:62984)
    at jg.dispose (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:236617)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Wg.listKernelsFromConnection (/home/zsiegel/.vscode-server/extensions/ms-toolsai.jupyter-2023.3.1201040234/out/extension.node.js:17:248904)

I don't know whether this is helpful. If there's anything I can do to make it easier to resolve this issue, please let me know. Thank you.

DonJayamanne commented 1 year ago

@zachsiegel-capsida Please can you create a separate issue, as it seems unrelated Also you mentioned that python environments too do not work

zachsiegel-capsida commented 1 year ago

@zachsiegel-capsida Please can you create a separate issue, as it seems unrelated Also you mentioned that python environments too do not work

@DonJayamanne I'm happy to open a separate issue, but since I was not experiencing my current issue before your update to address the previous issue, my best guess is that your update introduced a regression for Remote: WSL windows only.

If there's any information-gathering you'd like me to do (paste logs from the "Jupyter" extension output, test different configurations of opening notebooks, etc.), please say so and I'm happy to report on it in my new issue. Without any additional guidance, I'm not sure what else I can say besides "I can't connect to any Jupyter kernels from Remote: WSL windows".

Thank you so much for this wonderful extension.