e2b-dev / E2B

Secure open source cloud runtime for AI apps & AI agents
https://e2b.dev/docs
Apache License 2.0
6.95k stars 455 forks source link

WebSocket failed to start #334

Closed mlejva closed 3 months ago

mlejva commented 7 months ago

Some users have reported a WebSocket error when using our SDK that looks like this

WebSocket failed to start: WebSocket failed to start

The goal of this issue is to track the reported incidents while we're finding out the cause.

xiaotiancaipro commented 7 months ago

Yes, I encountered this error, and here is what it said:

INFO:e2b.sandbox.sandbox_connection:Sandbox fv7bfqp4wyo42829htzt created (id:ixooqqr5ho1dop95j39mc-3c0b8d1b)
INFO:e2b.sandbox.sandbox_connection:Started refreshing sandbox fv7bfqp4wyo42829htzt (id: ixooqqr5ho1dop95j39mc-3c0b8d1b)
INFO:e2b.sandbox.sandbox_rpc:WebSocket waiting to start
ERROR:e2b.sandbox.sandbox_rpc:WebSocket failed to start
ERROR:e2b.sandbox.sandbox_connection:WebSocket failed to start: WebSocket failed to start
INFO:e2b.sandbox.sandbox_connection:Closing sandbox fv7bfqp4wyo42829htzt (id: ixooqqr5ho1dop95j39mc-3c0b8d1b)
ERROR:core.application_manager:Unknown Error when generating
Traceback (most recent call last):
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_rpc.py", line 109, in connect
    raise TimeoutException("WebSocket failed to start")
e2b.sandbox.exception.TimeoutException: WebSocket failed to start

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/xiaotiancaipro/Documents/test/api/core/application_manager.py", line 214, in _generate_worker
    runner.run(
  File "/Users/xiaotiancaipro/Documents/test/api/core/app_runner/assistant_app_runner.py", line 336, in run
    self._handle_invoke_result(
  File "/Users/xiaotiancaipro/Documents/test/api/core/app_runner/app_runner.py", line 235, in _handle_invoke_result
    self._handle_invoke_result_stream(
  File "/Users/xiaotiancaipro/Documents/test/api/core/app_runner/app_runner.py", line 268, in _handle_invoke_result_stream
    for result in invoke_result:
  File "/Users/xiaotiancaipro/Documents/test/api/core/features/assistant_pos_runner.py", line 67, in run
    task_scheduler = Scheduler(
  File "/Users/xiaotiancaipro/Documents/test/api/core/scheduler.py", line 60, in __init__
    self.__run_task_chain()
  File "/Users/xiaotiancaipro/Documents/test/api/core/scheduler.py", line 282, in __run_task_chain
    task_result = task.run()
  File "/Users/xiaotiancaipro/Documents/test/api/core/tools/data_analysis_tool.py", line 112, in run
    flag, stdout, stderr, artifacts = self.__run_code(file=file, code=code)
  File "/Users/xiaotiancaipro/Documents/test/api/core/tools/data_analysis_tool.py", line 173, in __run_code
    flag = sandbox.create()
  File "/Users/xiaotiancaipro/Documents/test/api/clients/sandbox_client.py", line 17, in create
    self.__client = CodeInterpreter(api_key=config.E2B_API_KEY)
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/templates/data_analysis.py", line 46, in __init__
    super().__init__(
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/main.py", line 135, in __init__
    super().__init__(
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_connection.py", line 132, in __init__
    self._open(metadata=metadata, timeout=timeout)
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/main.py", line 316, in _open
    super()._open(metadata=metadata, timeout=timeout)
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_connection.py", line 278, in _open
    raise e
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_connection.py", line 274, in _open
    self._connect_rpc(timeout)
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_connection.py", line 289, in _connect_rpc
    self._rpc.connect(timeout=timeout)
  File "/opt/anaconda3/envs/test/lib/python3.10/site-packages/e2b/sandbox/sandbox_rpc.py", line 116, in connect
    raise SandboxException(f"WebSocket failed to start: {e}") from e
e2b.sandbox.exception.SandboxException: WebSocket failed to start: WebSocket failed to start

My code is :

from e2b import CodeInterpreter
client = CodeInterpreter(api_key=config.E2B_API_KEY)

and the version is e2b==0.14.4.

mlejva commented 7 months ago

Another user reported a following error

HTTPException(status_code=400, detail='WebSocket failed to start: WebSocket failed to start')
ValentaTomas commented 3 months ago

The new beta SDK (https://e2b.dev/docs/guide/beta-migration) does not use websockets — this bug is no longer relevant.