microsoft / vscode-jupyter

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

Failed to connect the jupyter server with an openssl setting #2222

Closed snio89 closed 3 years ago

snio89 commented 4 years ago

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Install Python extension to VS Code.
  2. Open ipython notebook file.
  3. CTRL+SHIFT+P -> 'Python: Specify local or remote Jupyter server for connections'.
  4. Insert remote jupyter server URI "https://(server_ip):(server_port)/", which the password and openssl settings are applied.
  5. Run a cell with "print('abc')" in the ipython notebook.

Actual behavior

Following error message is printed:

Error: Failed to connect to remote Jupyter notebook. Check that the Jupyter Server URI setting has a valid running server specified. https://(server_ip):(server_port)/ r: request to https://(server_ip):(server_port)/login? failed, reason: write EPROTO 41308680:error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL:../../third_party/boringssl/src/ssl/handshake_client.cc:568: at c:\Users\(remote_user)\.vscode\extensions\ms-python.python-2020.2.64397\src\client\datascience\jupyter\jupyterExecution.ts:206:39

Expected behavior

"abc" is printed.

Your Jupyter and/or Python environment

Please provide as much info as you readily know

More Descriptions

I've set my Jupyter server environment as the one described in the official jupyter notebook page. https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#securing-a-notebook-server

What I did:

The resulting jupyter server does not have any problem except the warning about the unreliable certificate when I access through the web browser as https://(server_ip):(server_port). However, when I attempt to access it through the VS Code, it produces a connection error as above.

It seems like the bug with an openssl certificate. When I remove the openssl certificate from the server and access http://(server_ip):(server_port) from the VS Code, no error happens and the code works as expected.

I've tried other options such as below but nothing helped.

*: suggested as a solution for https://github.com/microsoft/vscode-python/issues/4987

Developer Tools Console Output

notificationsAlerts.ts:40 Failed to connect to remote Jupyter notebook. Check that the Jupyter Server URI setting has a valid running server specified. https://(server_ip):(server_port)/ r: request to https://(server_ip):(server_port)/login? failed, reason: write EPROTO 41308680:error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL:../../third_party/boringssl/src/ssl/handshake_client.cc:568: onDidNotificationChange @ notificationsAlerts.ts:40

console.ts:137 [Extension Host] Error Python Extension: 2020-03-01 15:48:13: DataScience Error Error: Failed to connect to remote Jupyter notebook. Check that the Jupyter Server URI setting has a valid running server specified. https://(server_ip):(server_port)/ r: request to https://(server_ip):(server_port)/login? failed, reason: write EPROTO 41308680:error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL:../../third_party/boringssl/src/ssl/handshake_client.cc:568: at c:\Users\(remote_user)\.vscode\extensions\ms-python.python-2020.2.64397\src\client\datascience\jupyter\jupyterExecution.ts:206:39 t.log @ console.ts:137

2console.ts:137 [Extension Host] (node:14648) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. t.log @ console.ts:137

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer

DavidKutu commented 4 years ago

Hi @snio89, sorry to hear you're having trouble. I was just able to create a server with an openssl self signed certificate and got it to connect and work. Like you mentioned the 'python.dataScience.allowUnauthorizedRemoteConnection' setting must be on.

I had a couple of questions:

  1. What is your openssl version? (mine is OpenSSL 1.1.0g 2 Nov 2017 (Library: OpenSSL 1.1.1 11 Sep 2018))
  2. I see you can access it through the browser, but can you check your firewall anyway? Just in case.
snio89 commented 4 years ago

@DavidKutu After testing firewall settings and various versions of openssl, I've found the source of this problem.

Here's the link that are related to this problem. https://github.com/cypress-io/cypress/issues/5446#issuecomment-546427333 https://github.com/cypress-io/cypress/issues/5446#issuecomment-571178433

It seems to be the certification created by openssl has a compatibility issue with the boringssl library in TLS connection (not sure because I don't have much knowledge about networks).

I've changed the jupyter notebook setting as below to force TLS v1.2 connection instead of TLS v1.0.

https://github.com/jupyter/notebook/issues/3790 c.NotebookApp.ssl_options = {'ssl_version': 5}

Everything works fine now but I cannot sure this is a bug of vscode-python or jupyter notebook.

DavidKutu commented 4 years ago

I'm glad you got it to work. I'll keep this open as a reminder to dive deeper later.