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.

Cannot connect to a remote Jupyter server created via AWS Sagemaker

See original GitHub issue

Environment data

  • VS Code version:
1.39.2
6ab598523be7a800d7f3eb4d92d7ab9a66069390
x64
  • Extension version (available under the Extensions sidebar): 2019.10.44104
  • OS and version: macOS 10.14.6 (18G103)
  • Python version (& distribution if applicable, e.g. Anaconda): N/A (remote session)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A (remote session)
  • Relevant/affected Python packages and their versions: N/A (remote session)
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info microsoft/vscode-python#3977): N/A (remote session)

Expected behaviour

Can connect to the remote server

Actual behaviour

Executing code failed : Error: Failed to connect to remote Jupyter notebook. Check that the Jupyter Server URI setting has a valid running server specified. https://test-notebook-instance.notebook.us-east-1.sagemaker.aws/ Error: Invalid response: 200 OK

Other reports: https://superuser.com/questions/1492931/how-to-connect-sagemaker-notebook-from-vs-code

See Logs further down.

Steps to reproduce:

  1. Start the Sagemaker notebook
aws --profile personal-sagemaker --region us-east-1 sagemaker create-notebook-instance --notebook-instance-name test-notebook-instance --instance-type ml.t2.medium --role-arn  <my_role>

# wait for instance to start
aws --profile personal-sagemaker --region us-east-1 sagemaker create-presigned-notebook-instance-url --notebook-instance-name test-notebook-instance
  1. The above gives a https://test-notebook-instance.notebook.us-east-1.sagemaker.aws?authToken=<LONG_TOKEN> url.

  2. On a Python file opened:

# %%

print('hey')

I enter the URI in Python: Specify Jupyter Server URI and Type in (...)

Note

  1. I can use this notebook on the browser.
  2. Invalid response: 200 OK
  3. AWS returns a authToken query parameter on the url, but I tested both authToken and token query parameters with the same value just in case (and both together in the same url)
  4. Relevant lines:

Logs

Found this on the dev tools console, not sure what’s the best way to pass these over.

console.ts:137 [Extension Host] rejected promise not handled within 1 second: n: invalid json response body at https://console.aws.amazon.com/sagemaker/home?region=us-east-1&notebookState=L2FwaS9rZXJuZWxzcGVjcw%3D%3D#/notebook-instances/openNotebook/test-notebook-instance reason: Unexpected token < in JSON at position 2
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
console.ts:137 [Extension Host] stack trace: n: invalid json response body at https://console.aws.amazon.com/sagemaker/home?region=us-east-1&notebookState=L2FwaS9rZXJuZWxzcGVjcw%3D%3D#/notebook-instances/openNotebook/test-notebook-instance reason: Unexpected token < in JSON at position 2	at /Users/nqb/.vscode/extensions/ms-python.python-2019.10.44104/out/client/node_modules/@jupyterlab/services.js:1:207827	at process._tickCallback (internal/process/next_tick.js:68:7)
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
mainThreadExtensionService.ts:65 [[object Object]]invalid json response body at https://console.aws.amazon.com/sagemaker/home?region=us-east-1&notebookState=L2FwaS9rZXJuZWxzcGVjcw%3D%3D#/notebook-instances/openNotebook/test-notebook-instance reason: Unexpected token < in JSON at position 2
$onExtensionRuntimeError @ mainThreadExtensionService.ts:65
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
mainThreadExtensionService.ts:66 n: invalid json response body at https://console.aws.amazon.com/sagemaker/home?region=us-east-1&notebookState=L2FwaS9rZXJuZWxzcGVjcw%3D%3D#/notebook-instances/openNotebook/test-notebook-instance reason: Unexpected token < in JSON at position 2
	at /Users/nqb/.vscode/extensions/ms-python.python-2019.10.44104/out/client/node_modules/@jupyterlab/services.js:1:207827
	at process._tickCallback (internal/process/next_tick.js:68:7)
$onExtensionRuntimeError @ mainThreadExtensionService.ts:66
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
greazercommented, Oct 24, 2019

Thank for the issue!

0reactions
xerdinkcommented, Jan 26, 2021

I have still this issue? I cannot connect with awsToken created with presigned URL?

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't open Jupyter on my Amazon SageMaker notebook ...
1. Open the Jupyter dashboard, and then choose the Files tab. · 2. Choose New, and then choose Terminal. · 3. Run a...
Read more >
Troubleshoot issues with associating Git repositories ... - AWS
I'm trying to add a Git repository to an Amazon SageMaker notebook instance, but I'm getting one or more of the following errors:....
Read more >
Troubleshoot SageMaker notebook connectivity issues
Can't establish connection between Jupyter and the browser · Restart your notebook instance. · Restart your browser, clear your browser cache, or ...
Read more >
Access Notebook Instances - Amazon SageMaker
To access your Amazon SageMaker notebook instances, choose one of the following ... Use the Jupyter notebook dashboard to create and manage notebooks...
Read more >
Resolve the ModuleNotFoundError on an Amazon SageMaker ...
When you use pip to install the Python library on the notebook instance, the library is available only to the local notebook instance....
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