Hello everyone,I'm stuck, I've tried two ways and none of them work for me.
$(function() { $("#btres").click(function() { $.post( "code:factorial(10)", function(d, st, xhr) { alert(xhr.responseText); }, "json" ); })}){"execute_reply": {"status": "ok", "execution_count": 0, "user_expressions": {}, "payload": []}, "success": true}
$(function() { $("#btres").click(function() { $.post( wsconnect, "json" ); })})
var shlws, iopws;function wsconnect(data, st, xhr) { var wsshell = data.ws_url + "kernel/" + data.id + "/shell"; var wsiopub = data.ws_url + "kernel/" + data.id + "/iopub"; alert(wsshell); alert(wsiopub); try { shlws = new WebSocket(wsshell); iopws = new WebSocket(wsiopub); } catch(e) { alert(e); }}WebSocket connection to 'wss://sagecell.sagemath.org/kernel/0bd6d4cc-8d9f-4ee3-bf00-5d2d3ec57cc2/shell' failed: Error during WebSocket handshake: Unexpected response code: 404WebSocket connection to 'wss://sagecell.sagemath.org/kernel/0bd6d4cc-8d9f-4ee3-bf00-5d2d3ec57cc2/iopub' failed: Error during WebSocket handshake: Unexpected response code: 404surl = data.ws_url + "kernel/" + data.id + "/channels";try { wso = new WebSocket(surl);} catch(e) { alert(e);}WebSocket connection to 'wss://sagecell.sagemath.org/kernel/74d6b265-9e9d-4eea-b6a6-ef6d1ace3da1/channels' failed: Error during WebSocket handshake: Unexpected response code: 403
Hello Andrey,
I replaced the shell/iopub pair with:surl = data.ws_url + "kernel/" + data.id + "/channels";try {wso = new WebSocket(surl);} catch(e) {alert(e);}
And now the error is:WebSocket connection to 'wss://sagecell.sagemath.org/kernel/74d6b265-9e9d-4eea-b6a6-ef6d1ace3da1/channels' failed: Error during WebSocket handshake: Unexpected response code: 403I guess the error is because I do not include the header:Jupyter-Kernel-ID:" + data.idwhen I create the websocketThe issue is that the Javascript Websocket API does not allow to include a header just like the Python API doesI think SockJS API does not allow it either
On Saturday, 4 November 2017 17:51:07 UTC-6, Jorge Manrique wrote:Hello Andrey,I replaced the shell/iopub pair with:surl = data.ws_url + "kernel/" + data.id + "/channels";try {wso = new WebSocket(surl);} catch(e) {alert(e);}
And now the error is:WebSocket connection to 'wss://sagecell.sagemath.org/kernel/74d6b265-9e9d-4eea-b6a6-ef6d1ace3da1/channels' failed: Error during WebSocket handshake: Unexpected response code: 403I guess the error is because I do not include the header:Jupyter-Kernel-ID:" + data.idwhen I create the websocketThe issue is that the Javascript Websocket API does not allow to include a header just like the Python API doesI think SockJS API does not allow it either
Is it somehow against socket standards that no custom headers can be added? It is used for load balancing and gives much better results than alternatives (which are cookies that tend to create new and new troubles or IP addresses). It is probably possible to add another matching rule like the one for files https://github.com/sagemath/sagecell/blob/master/contrib/vm/container_manager.py#L264 to make all URLs with explicit kernel id match it.