Intermittently occuring "Connection Failed" error nesccessitates cache refresh on Firefox for temporary fix
- Dominant language
- Jupyter Notebook
- Stars
- 13.3k
- Forks
- 5.8k
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 7
Description
I recently updated two workstations (Arch) including jupyter-notebook 5.3.0-3 -> 5.3.0-4. Since then, I've been having a strange issue with using Jupyter via SSH port forwarding. If I try to open a notebook on Firefox (61.0.2) by connecting to localhost:8888, I get the standard "Connection Failed" error. Looking at the web console in Firefox I get the following output which makes me think it's a websocket error.
```bash
Use of Mutation Events is deprecated. Use MutationObserver instead. jquery.min.js:5
actions jupyter-notebook:find-and-replace does not exist, still binding it in case it will be defined later... menubar.js:304
accessing "actions" on the global IPython/Jupyter is not recommended. Pass it to your objects contructors at creation time main.js:208
Loaded moment locale en bidi.js:19
load_extensions
Arguments { 0: "jupyter-js-widgets/extension", … }
utils.js:60
Loading extension: jupyter-js-widgets/extension utils.js:37
Session: kernel_created (33583303-de4a-42c6-8b8b-b14e2573fda6) session.js:54
Starting WebSockets: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 kernel.js:459
Firefox can’t establish a connection to the server at ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856/channels?session_id=E94F7CA503584275A5037A15B0AC6E23. kernel.js:461
Kernel: kernel_disconnected (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
WebSocket connection failed: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 true kernel.js:544
Connection lost, reconnecting in 1 seconds. kernel.js:562
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at about:blank. (Reason: CORS request not http).
Kernel: kernel_reconnecting (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
Starting WebSockets: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 kernel.js:459
Firefox can’t establish a connection to the server at ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856/channels?session_id=E94F7CA503584275A5037A15B0AC6E23. kernel.js:461
Kernel: kernel_disconnected (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
WebSocket connection failed: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 true kernel.js:544
Connection lost, reconnecting in 2 seconds. kernel.js:562
Kernel: kernel_reconnecting (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
Starting WebSockets: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 kernel.js:459
Firefox can’t establish a connection to the server at ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856/channels?session_id=E94F7CA503584275A5037A15B0AC6E23. kernel.js:461
Kernel: kernel_disconnected (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
WebSocket connection failed: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 true kernel.js:544
Connection lost, reconnecting in 4 seconds. kernel.js:562
Kernel: kernel_reconnecting (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
Starting WebSockets: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 kernel.js:459
Firefox can’t establish a connection to the server at ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856/channels?session_id=E94F7CA503584275A5037A15B0AC6E23. kernel.js:461
Kernel: kernel_disconnected (7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856) kernel.js:103
WebSocket connection failed: ws://localhost:8888/api/kernels/7e7b81aa-d0a0-4a5a-be2c-cba2c4e67856 true kernel.js:544
Connection lost, reconnecting in 8 seconds.
```
On the server side, I see this:
```bash
[I 11:02:20.033 NotebookApp] Creating new notebook in /notebooks
[I 11:02:21.686 NotebookApp] Kernel started: 7b8c19b0-835f-4448-bdc1-700ec02eb4ff
[I 11:02:29.361 NotebookApp] Saving file at /notebooks/Untitled.ipynb
```
When I try to refresh the browser, I see no activity on the jupyter server. However, if I clear the cache in Firefox or if I open the same url in Safari or Chrome, it works. However, after a while (in Firefox at least) the same error comes up again, necessitating another cache refresh. I haven’t used Safari or Chrome for very long so I don’t know if the error pops up there as well for me.
What’s also interesting is this is reproducible on multiple machines in the building running Arch, but my colleague who uses Safari has not seen the error. Any idea where to look? I would usually expect a websocket issue to be a problem with the network, but the fact that a cache refresh fixes the problem sounds like something “bad” is getting cached.
Update 8/23: Today this happened again and I had to both refresh the cache on Firefox *and* restart the jupyter server. All the while jupyter is working fine through safari.
Contributor guide
Research direction
Reproduce the intermittent Firefox failure through SSH port forwarding and inspect the websocket connection initiated in kernel.js, especially the /api/kernels/.../channels path. Compare the Firefox behavior with the NotebookApp server logs and other browsers; the issue is done when the websocket connects reliably without clearing the browser cache or restarting the server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100