OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

"ERROR: WebSocket connection is not ready" - communication between backend and frontend not working as intended

Open unk1nd opened this issue 10 months ago • 4 comments

Describe the bug

Stuck at ERROR: WebSocket connection is not ready. Communication between backend and frontend not working as intended.

Setup and configuration

Current version:

root@Dorrisv2:~/OpenDevin/logs# git log -n 1
commit 01c4c4bee4b5d8dc227e3432f585229a7c9d7126 (HEAD -> main, origin/main, origin/HEAD)
Author: ITNerdAZ <[email protected]>
Date:   Mon Apr 8 14:56:02 2024 +0000

    Add installation warning to readme (#883)

    * Update README

    * Update README.md

    ---------

    Co-authored-by: Robert Brennan <[email protected]>

My config.toml and environment vars (be sure to redact API keys):

#LLM_MODEL="gpt-3.5-turbo-1106"
LLM_API_KEY="sk-0LP6BRo2-YA-MAMA"
#LLM_EMBEDDING_MODEL="openai"
WORKSPACE_DIR="./workspace"

Running in clean Windows WSL with the Ubuntu 22.04 env. Docker Desktop passed in to WSL.

Commands I ran to install and run OpenDevin as root:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20
curl -sSL https://install.python-poetry.org | python3 -
export PATH="/root/.local/bin:$PATH"
git clone https://github.com/OpenDevin/OpenDevin.git
cd OpenDevin
apt install make
make build
make setup-config
mkdir workspace
tmux
make start-frontend
make start-backend

Steps to Reproduce:

  1. Following commands at above
  2. Open http://localhost:3001
  3. See WebSocket error

Logs, error messages, and screenshots: Console output:

root@Dorrisv2:~/OpenDevin# make start-backend
Starting backend...
The currently activated Python version 3.10.6 is not supported by the project (^3.11).
Trying to find and use a compatible version.
Using python3.11 (3.11.9)
/root/.cache/pypoetry/virtualenvs/opendevin-j196sbkk-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_list" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
/root/.cache/pypoetry/virtualenvs/opendevin-j196sbkk-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_name" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
/root/.cache/pypoetry/virtualenvs/opendevin-j196sbkk-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_group_alias" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
/root/.cache/pypoetry/virtualenvs/opendevin-j196sbkk-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_info" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
/root/.cache/pypoetry/virtualenvs/opendevin-j196sbkk-py3.11/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_id" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
  warnings.warn(
INFO:     Started server process [8163]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
INFO:     127.0.0.1:53012 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     127.0.0.1:53026 - "GET /messages/total HTTP/1.1" 200 OK
INFO:     127.0.0.1:53024 - "GET /configurations HTTP/1.1" 200 OK
INFO:     127.0.0.1:53040 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 48182) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiJjYWI5MGI4MC03NDA2LTQ2NjMtODM1OC0wMDM4ZmU2YzgzZmIifQ.qcXYZUuO5i81Xt2I-xKrS9qK0tpKEo-Sl97yPqej6aY" [accepted]
Starting loop_recv for sid: cab90b80-7406-4663-8358-0038fe6c83fb, False
INFO:     connection open
INFO:     ('127.0.0.1', 48196) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiJjYWI5MGI4MC03NDA2LTQ2NjMtODM1OC0wMDM4ZmU2YzgzZmIifQ.qcXYZUuO5i81Xt2I-xKrS9qK0tpKEo-Sl97yPqej6aY" [accepted]
Starting loop_recv for sid: cab90b80-7406-4663-8358-0038fe6c83fb, False
INFO:     connection open
19:24:16 - opendevin:INFO: session.py:38 - WebSocket disconnected, sid: cab90b80-7406-4663-8358-0038fe6c83fb
INFO:     connection closed
19:24:16 - opendevin:INFO: session.py:38 - WebSocket disconnected, sid: cab90b80-7406-4663-8358-0038fe6c83fb
INFO:     connection closed
INFO:     127.0.0.1:56078 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     127.0.0.1:56086 - "GET /configurations HTTP/1.1" 200 OK
INFO:     127.0.0.1:56090 - "GET /messages/total HTTP/1.1" 200 OK
INFO:     127.0.0.1:56104 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 56106) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiJjYWI5MGI4MC03NDA2LTQ2NjMtODM1OC0wMDM4ZmU2YzgzZmIifQ.qcXYZUuO5i81Xt2I-xKrS9qK0tpKEo-Sl97yPqej6aY" [accepted]
Starting loop_recv for sid: cab90b80-7406-4663-8358-0038fe6c83fb, False
INFO:     connection open
INFO:     ('127.0.0.1', 56114) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiJjYWI5MGI4MC03NDA2LTQ2NjMtODM1OC0wMDM4ZmU2YzgzZmIifQ.qcXYZUuO5i81Xt2I-xKrS9qK0tpKEo-Sl97yPqej6aY" [accepted]
Starting loop_recv for sid: cab90b80-7406-4663-8358-0038fe6c83fb, False
INFO:     connection open
root@Dorrisv2:~/OpenDevin# make start-frontend
Starting frontend...

> [email protected] start
> vite


  VITE v5.2.8  ready in 332 ms

  ➜  Local:   http://localhost:3001/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

Screenshot: image

Logs for that session:

root@Dorrisv2:~/OpenDevin# cat logs/opendevin_2024-04-08_19-23-44.log
19:24:16 - opendevin:INFO: session.py:38 - WebSocket disconnected, sid: cab90b80-7406-4663-8358-0038fe6c83fb
19:24:16 - opendevin:INFO: session.py:38 - WebSocket disconnected, sid: cab90b80-7406-4663-8358-0038fe6c83fb

Additional Context

Docker:

root@Dorrisv2:~/OpenDevin# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
ghcr.io/opendevin/sandbox   latest    7a17fca0b46c   12 hours ago   560MB

root@Dorrisv2:~/OpenDevin# docker --version
Docker version 25.0.3, build 4debf41

root@Dorrisv2:~/OpenDevin# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

make build:

root@Dorrisv2:~/OpenDevin# make build
Building project...
Checking dependencies...
Checking Python installation...
Python 3.10.6 is already installed.
Checking npm installation...
npm 10.5.0 is already installed.
Checking Docker installation...
Docker version 25.0.3, build 4debf41 is already installed.
Checking Poetry installation...
Poetry (version 1.8.2) is already installed.
Dependencies checked successfully.
Pulling Docker image...
Using default tag: latest
latest: Pulling from opendevin/sandbox
Digest: sha256:b051045dd07803ec72da0342fca84d287f77c46ebde0ee2d57f551b863c8894e
Status: Image is up to date for ghcr.io/opendevin/sandbox:latest
ghcr.io/opendevin/sandbox:latest

What's Next?
  1. Sign in to your Docker account → docker login
  2. View a summary of image vulnerabilities and recommendations → docker scout quickview ghcr.io/opendevin/sandbox
Docker image pulled successfully.
Installing Python dependencies...
The currently activated Python version 3.10.6 is not supported by the project (^3.11).
Trying to find and use a compatible version.
Using python3.11 (3.11.9)
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: opendevin (0.1.0)
Python dependencies installed successfully.
Setting up frontend environment...
Detect Node.js version...
Current Node.js version is 20.12.1, corepack is supported.
Installing frontend dependencies with npm...

> [email protected] prepare
> cd .. && husky install frontend/.husky

husky - Git hooks installed

up to date, audited 996 packages in 2s

206 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Running make-i18n with npm...

> [email protected] make-i18n
> node scripts/make-i18n-translations.cjs

Frontend dependencies installed successfully.
Installing pre-commit hooks...
The currently activated Python version 3.10.6 is not supported by the project (^3.11).
Trying to find and use a compatible version.
Using python3.11 (3.11.9)
pre-commit installed at .git/hooks/pre-commit
Pre-commit hooks installed successfully.
Build completed successfully.

unk1nd avatar Apr 08 '24 17:04 unk1nd

root@Dorrisv2:~/OpenDevin# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3001          0.0.0.0:*               LISTEN      8274/node
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      8163/python
udp        0      0 127.0.0.1:323           0.0.0.0:*                           -
udp6       0      0 ::1:323                 :::*                                -

added netstats as well

unk1nd avatar Apr 08 '24 17:04 unk1nd

Backend started successfully.
Starting frontend with npm...

> [email protected] start
> vite --port 3001


  VITE v5.2.8  ready in 338 ms

  ➜  Local:   http://localhost:3001/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
INFO:     127.0.0.1:55456 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     127.0.0.1:55466 - "GET /messages/total HTTP/1.1" 200 OK
INFO:     127.0.0.1:55464 - "GET /configurations HTTP/1.1" 200 OK
INFO:     127.0.0.1:55480 - "GET /refresh-files HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 55492) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiIzZTNhYzkwZi1lMzg1LTRlYWUtOWZkNy1jMmVhMmMzYzcyZDQifQ.kKnsuhrpxCvy67ai-ddxMzcxrK_8zBqdH6AgW7G7PXk" [accepted]
Starting loop_recv for sid: 3e3ac90f-e385-4eae-9fd7-c2ea2c3c72d4, False
INFO:     connection open
INFO:     ('127.0.0.1', 55498) - "WebSocket /ws?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiIzZTNhYzkwZi1lMzg1LTRlYWUtOWZkNy1jMmVhMmMzYzcyZDQifQ.kKnsuhrpxCvy67ai-ddxMzcxrK_8zBqdH6AgW7G7PXk" [accepted]
Starting loop_recv for sid: 3e3ac90f-e385-4eae-9fd7-c2ea2c3c72d4, False
INFO:     connection open

I am having the same issue... Config: WSL2 - Ubuntu

LLM_MODEL="ollama/codellama"
LLM_API_KEY="ollama"
LLM_EMBEDDING_MODEL="llama2"
LLM_BASE_URL="http://localhost:11434"
WORKSPACE_DIR="./workspace"

JayQuimby avatar Apr 08 '24 23:04 JayQuimby

Can you try this branch to see if it helps? https://github.com/OpenDevin/OpenDevin/pull/890

Although, some hit this issue, some didn't. Perhaps start separately backend and frontend, giving backend a bit of time to see it started.

enyst avatar Apr 08 '24 23:04 enyst

Can you try this branch to see if it helps? #890

Although, some hit this issue, some didn't. Perhaps start separately backend and frontend, giving backend a bit of time to see it started.

That did the trick... thank you @enyst!

JayQuimby avatar Apr 08 '24 23:04 JayQuimby

Fixed by : #941 you can now pull the latest changes!

dorbanianas avatar Apr 09 '24 15:04 dorbanianas

I encountered the same problem.

DXLgpt avatar Apr 10 '24 12:04 DXLgpt

try to close the browser where you ran the app, and run make run after the successful execution of the frontend try to open the app this worked with me

dorbanianas avatar Apr 10 '24 15:04 dorbanianas