question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iqsharp jupyter kernel connection fails due to tornado timeout error

See original GitHub issue

Short description: Unable to establish connection to Q# kernel in Jupyter notebook due to tornado\websocket.py timeout

Relevant error message: Traceback (most recent call last): File “C:\Users\koberm01.conda\envs\qsharp-env\lib\site-packages\tornado\websocket.py”, line 956, in _accept_connection await open_result tornado.util.TimeoutError: Timeout

Steps:

  1. Follow instructions for installing the IQ# kernel using conda at https://docs.microsoft.com/en-us/quantum/quickstarts/install-jupyter?tabs=tabid-conda. Note: launch conda prompt using Run as Admin option.
  2. Launch Jupyter from conda qsharp-env
  3. Create new Q# notebook with SampleQuantumRandomNumberGenerator code
  4. Unable to run notebook cells due to kernel connection issue as can be seen from log below

Expected behavior: Being able to execute the SampleQuantumRandomNumberGenerator code in a new Q# notebook.

Environment details: Windows 10 Enterprise Version 10.0.17763 Build 17763 conda 4.9.2 (Anaconda 64 bit installation) python 3.7.9 tornado 6.1 iqsharp 0.14.2011.120240 jupyter-core 4.7.0 dotnet 3.1.404

Steps taken to resolve (unsuccessful): a. Some research indicated that downgrading tornado to 5.1.1 may resolve the issue, but that was tried and triggered other errors so tornado was returned to 6.1. Example: https://github.com/tornadoweb/tornado/issues/2651 b. Also tried the option to install IQ# using .NET CLI. Installed without error but creating a new Q# Jupyter notebook produces the same error.

Output from conda prompt (Run as Admin):

(base) C:\windows\system32>conda activate qsharp-env

(qsharp-env) C:\windows\system32>python -c "import qsharp"
Preparing Q# environment...

(qsharp-env) C:\windows\system32>jupyter notebook
[I 10:00:25.072 NotebookApp] Serving notebooks from local directory: C:/ko-jupyter-notebooks
[I 10:00:25.072 NotebookApp] Jupyter Notebook 6.1.6 is running at:
[I 10:00:25.073 NotebookApp] http://localhost:8888/?token=67e7d25a2acd41b9f64873b0d0ac52bb0bd9ca1584ea7434
[I 10:00:25.073 NotebookApp]  or http://127.0.0.1:8888/?token=67e7d25a2acd41b9f64873b0d0ac52bb0bd9ca1584ea7434
[I 10:00:25.074 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:00:25.240 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/koberm01/AppData/Roaming/jupyter/runtime/nbserver-12136-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=67e7d25a2acd41b9f64873b0d0ac52bb0bd9ca1584ea7434
     or http://127.0.0.1:8888/?token=67e7d25a2acd41b9f64873b0d0ac52bb0bd9ca1584ea7434
[I 10:00:39.921 NotebookApp] Kernel started: 05b90f39-524b-4b7f-a950-aec261df8be2, name: iqsharp
[I 10:00:44.680 NotebookApp] Adapting from protocol version 5.2.0 (kernel 05b90f39-524b-4b7f-a950-aec261df8be2) to 5.3 (client).
[W 10:00:49.214 NotebookApp] Nudge: attempt 10 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:00:54.214 NotebookApp] Nudge: attempt 20 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:00:59.202 NotebookApp] Nudge: attempt 30 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:04.213 NotebookApp] Nudge: attempt 40 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:09.206 NotebookApp] Nudge: attempt 50 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:14.213 NotebookApp] Nudge: attempt 60 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:19.215 NotebookApp] Nudge: attempt 70 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:24.235 NotebookApp] Nudge: attempt 80 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:29.267 NotebookApp] Nudge: attempt 90 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:34.279 NotebookApp] Nudge: attempt 100 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:39.295 NotebookApp] Nudge: attempt 110 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[W 10:01:44.282 NotebookApp] Nudge: attempt 120 on kernel 05b90f39-524b-4b7f-a950-aec261df8be2
[E 10:01:44.704 NotebookApp] Uncaught exception GET /api/kernels/05b90f39-524b-4b7f-a950-aec261df8be2/channels?session_id=e9e4538223d64b959245f8941e87102a (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernels/05b90f39-524b-4b7f-a950-aec261df8be2/channels?session_id=e9e4538223d64b959245f8941e87102a', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\Users\koberm01\.conda\envs\qsharp-env\lib\site-packages\tornado\websocket.py", line 956, in _accept_connection
        await open_result
    tornado.util.TimeoutError: Timeout
[W 10:01:45.729 NotebookApp] Replacing stale connection: 05b90f39-524b-4b7f-a950-aec261df8be2:e9e4538223d64b959245f8941e87102a
[I 10:02:39.716 NotebookApp] Saving file at /QSharpPracticeKO/TestQSharp.ipynb

Screenshot of notebook: image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ricardo-espinozacommented, Jan 22, 2021

Hi all,

Thanks for reporting this issue. We’re aware of this timeout error, and we’re working on a fix that we expect to have available in the coming days. In the meantime, using a faster network connection can reduce the chances that you’ll get affected by this bug. We’ll update this issue in GitHub as soon as a fix becomes available.

QDK Team

0reactions
anjburcommented, Aug 19, 2021

@lfenster thank you for letting us know you’re seeing this problem! A new issue has been opened for it at #494. I tagged you there as well looking for debug logs of the issue, as we haven’t been able to reproduce it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to start Kernel due to connexion timeout - Jupyter ...
I encountered this error because I was using a system proxy. When I turned it off, jupyter worked fine. So I think the...
Read more >
Newly installed Jupyter Notebook, but it won't connect to Kernel
I have tried different ways found via google search (e.g. downgrading tornado, deactivating VPN/Anti-virus and etc.), but none of them has ...
Read more >
How to Fix Kernel Error in Jupyter Notebook
Most times these tools become complex to work with due to errors in ... So, a kernel error occurs when Jupyter fails to...
Read more >
What to do when things go wrong — Jupyter Notebook 7.0.2 ...
If Jupyter gives an error that it can't find notebook , check with pip or conda that the notebook package is installed. Try...
Read more >
Untitled
I am new to jupyter notebook and trying to run with give below errors. ... iqsharp jupyter kernel connection fails due to tornado...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found