Just to clarify, my mental model of what goes on is:

(1) Kernel <---- ZMQ ----> (2) JupyterServer(?) <--->  WebSockets(??) <---> 
(3) Jupyter WebApp/FrontEnd (in Browser) <---> (4) User Javascript/Wasm 
code (Inside the output of a cell)

I'm looking for a way to get (1, the kernel) and (4, the user 
javascript/wasm) to communicate.

>From poking around the debug messages, it seems there is a websocket port 
in (2, JupyterServe) in `/api/kernels/<session_id>/channels` ? Is this 
something my user code (4) can open a socket and communicate through, using 
the custom messages protocol ? 

I found this documentation on WebSocket protocol 
<https://jupyter-server.readthedocs.io/en/latest/developers/websocket-protocols.html>,
 
but it seems to be aimed at communication between (2) and (3). I'm not sure 
I'm able in (4) to connect to this websocket, and if it is, what is its 
address (maybe the one I pointed above?)

cheers

ps.: I found many other questions in stack overflow, Jupyter Forum, and even 
in this list <https://groups.google.com/g/jupyter/c/UPcTBWCS9bI>, but I'm 
missing some of the details, and most seem to be using/require some 
installed jupyter extension, which I wanted to avoid having to do -- much 
better if this works without needing to install other things, not mention 
having to manager another separate codebase for the extension :)
On Saturday, September 2, 2023 at 7:54:43 AM UTC+2 Jan Pfeifer wrote:

> hi all, 
>
> I’m trying to build something similar to ipywidgets but to the GoNB 
> kernel (a Go kernel) <https://github.com/janpfeifer/gonb>, and I’m trying 
> to figure out how to communicate from Javascript in the notebook to the 
> kernel.
>
> Any pointers ?
>
> The Kernel Message protocol suggests that one can use custom messages 
> <https://jupyter-client.readthedocs.io/en/latest/messaging.html#custom-messages>
>  (using 
> "Comm" channels, using the Shell socket on the kernel, and presumably the 
> IOPub in the Frontend)  for that. I also saw these messages passing by 
> when playing ipywidgets (in Python) and looking at the debug output of 
> JupyterLab.
>
> But how from Javascript (from an HTML widget) I tell Jupyter notebook to 
> send these messages to the kernel ? 
>
> Any pointers to documentation, or example source code I can get started ?
>
> many thanks!
>
> ps.: This is a repost from an old question in Jupyter Forum 
> <https://discourse.jupyter.org/t/how-in-javascript-to-send-a-comm-info-to-the-kernel/18620>,
>  
> for which I didn't get a reply (maybe wrong topic?)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/1650b889-6e2a-4ad5-9ceb-5975db4008a0n%40googlegroups.com.

Reply via email to