Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error resolving url: Get "http://127.0.0.1:9222/json/version": dial tcp 127.0.0.1:9222: connect: connection refused 0xc000431560 #53

Open
TrueNix opened this issue Apr 3, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@TrueNix
Copy link

TrueNix commented Apr 3, 2024

When I ask to navigate to some page.

Trying to get content from https://{reducted}/
2024/04/03 10:44:32 failed to process browser: %!w(*fmt.wrapError=&{failed to get content: Error loading page: Error resolving url: Get "http://127.0.0.1:9222/json/version": dial tcp 127.0.0.1:9222: connect: connection refused 0xc000431560})

Running from VM tried in bridge as well.

@semanser
Copy link
Owner

semanser commented Apr 3, 2024

This can happen if it can't reach the browser (which is running in a docker container). Could you run docker ps to make sure that it's running?

@TrueNix
Copy link
Author

TrueNix commented Apr 3, 2024

`2024/04/03 11:59:33 OK 20240325154630_initial_migration.sql (3.38ms)
2024/04/03 11:59:33 OK 20240325193843_add_logs_table.sql (9.06ms)
2024/04/03 11:59:33 OK 20240328114536_tool_call_id_field.sql (1.17ms)
2024/04/03 11:59:33 goose: successfully migrated database to version: 20240328114536
2024/04/03 11:59:33 Migrations ran successfully
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.

  • using env: export GIN_MODE=release
  • using code: gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] POST /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] PUT /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] PATCH /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] HEAD /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] OPTIONS /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] DELETE /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] CONNECT /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] TRACE /graphql --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] GET /playground --> github.com/semanser/ai-coder/router.New.playgroundHandler.func3 (5 handlers)
[GIN-debug] GET /terminal/:id --> github.com/semanser/ai-coder/router.New.wsHandler.func4 (5 handlers)
[GIN-debug] GET /browser/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (5 handlers)
[GIN-debug] HEAD /browser/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (5 handlers)
2024/04/03 11:59:33 Docker client initialized: truenix-virtual-machine
2024/04/03 11:59:33 Spawning container ghcr.io/go-rod/rod "codel-browser"
2024/04/03 11:59:33 Image ghcr.io/go-rod/rod found locally: true
2024/04/03 11:59:33 Creating container codel-browser...
2024/04/03 11:59:33 Container not found. Marking it as stopped.
2024/04/03 11:59:33 failed to initialize browser container: failed to spawn container: Error creating container: Error response from daemon: Conflict. The container name "/codel-browser" is already in use by container "11021dbeb4ed0f35579b4606078f64d4f03265527f6de62f7ca3ae8db3892d39". You have to remove (or rename) that container to be able to reuse that name.
`
That happened after reboot the machine

@TrueNix
Copy link
Author

TrueNix commented Apr 3, 2024

i've ran sudo docker container prune now it started:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
711173e27a59 ghcr.io/go-rod/rod "dumb-init -- chrome…" About a minute ago Up About a minute 0.0.0.0:9222->9222/tcp codel-browser
f43736519917 ghcr.io/semanser/codel:latest "/bin/sh -c /app" About a minute ago Up About a minute 0.0.0.0:3000->8080/tcp, :::3000->8080/tcp modest_matsumoto

2024/04/03 12:08:26 Spawning container debian:latest "codel-terminal-1"
2024/04/03 12:08:26 Image debian:latest found locally: true
2024/04/03 12:08:26 Creating container codel-terminal-1...
2024/04/03 12:08:26 Container codel-terminal-1 created
2024/04/03 12:08:26 Container codel-terminal-1 started
2024/04/03 12:08:26 Getting next task
2024/04/03 12:08:31 Command 2 added to the queue 1
2024/04/03 12:08:31 Waiting for a task
2024/04/03 12:08:31 Processing command 2 of type browser
2024/04/03 12:08:31 Trying to get content from https://{reducted}.com/
2024/04/03 12:08:31 failed to process browser: %!w(*fmt.wrapError=&{failed to get content: Error loading page: Error resolving url: Get "http://127.0.0.1:9222/json/version": dial tcp 127.0.0.1:9222: connect: connection refused 0xc0002e2040})
2024/04/03 12:08:31 Waiting for a task

@TrueNix
Copy link
Author

TrueNix commented Apr 3, 2024

curl http://127.0.0.1:9222/json/version from the VM:
{
"Browser": "HeadlessChrome/114.0.5720.0",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/114.0.5720.0 Safari/537.36",
"V8-Version": "11.4.118",
"WebKit-Version": "537.36 (@de21fd13ee1dbfb5c6056aa0220cf1b7f1e750d0)",
"webSocketDebuggerUrl": "ws://127.0.0.1:9222/devtools/browser/4ce8ee7d-0ccc-4855-a037-4eb9e0167523"
}

curl http://127.0.0.1:9222/json/version from the docker

curl: (7) Failed to connect to 127.0.0.1 port 9222 after 0 ms: Couldn't connect to server

@semanser
Copy link
Owner

semanser commented Apr 3, 2024

So you're running: Host -> VM -> Docker.

I suspect that running curl from the Docker is trying to bypass the VM and reach the host somehow.

@TrueNix
Copy link
Author

TrueNix commented Apr 3, 2024

Host -> VM -> Docker

exactly, VM configured as bridge btw

@semanser semanser added the bug Something isn't working label Apr 4, 2024
@semanser
Copy link
Owner

semanser commented Apr 4, 2024

What command did you use to run Codel? Did you use --network="host" by any chance? This could cause it not to work.

@robert-fahey
Copy link

robert-fahey commented Apr 4, 2024

Hey, thanks again for this project. I appear to be experiencing the same behaviour

I'm on macOS and using Orbstack FYI

make run              
docker run -e OPEN_AI_KEY=$OPENAI_API_KEY -p 3000:8080 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/semanser/codel:latest
2024/04/04 10:36:45 OK   20240325154630_initial_migration.sql (857.64µs)
2024/04/04 10:36:45 OK   20240325193843_add_logs_table.sql (753.43µs)
2024/04/04 10:36:45 OK   20240328114536_tool_call_id_field.sql (487.51µs)
2024/04/04 10:36:45 goose: successfully migrated database to version: 20240328114536
2024/04/04 10:36:45 Migrations ran successfully
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] POST   /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] PUT    /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] PATCH  /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] HEAD   /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] OPTIONS /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] DELETE /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] CONNECT /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] TRACE  /graphql                  --> github.com/semanser/ai-coder/router.graphqlHandler.func4 (5 handlers)
[GIN-debug] GET    /playground               --> github.com/semanser/ai-coder/router.New.playgroundHandler.func3 (5 handlers)
[GIN-debug] GET    /terminal/:id             --> github.com/semanser/ai-coder/router.New.wsHandler.func4 (5 handlers)
[GIN-debug] GET    /browser/*filepath        --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (5 handlers)
[GIN-debug] HEAD   /browser/*filepath        --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (5 handlers)
2024/04/04 10:36:45 Docker client initialized: orbstack
2024/04/04 10:36:45 Spawning container ghcr.io/go-rod/rod "codel-browser"
2024/04/04 10:36:45 Image ghcr.io/go-rod/rod found locally: true
2024/04/04 10:36:45 Creating container codel-browser...
2024/04/04 10:36:45 Container codel-browser created
2024/04/04 10:36:46 Container codel-browser started
2024/04/04 10:36:46 connect to http://localhost:8080/playground for GraphQL playground
[GIN] 2024/04/04 - 10:37:22 | 301 |     238.127µs |   192.168.215.1 | GET      "/chat/3"
[GIN] 2024/04/04 - 10:37:22 | 304 |      91.709µs |   192.168.215.1 | GET      "/"
[GIN] 2024/04/04 - 10:37:22 | 304 |     124.376µs |   192.168.215.1 | GET      "/assets/index-D0p-o-St.css"
[GIN] 2024/04/04 - 10:37:22 | 200 |    3.127118ms |   192.168.215.1 | GET      "/assets/index-DLFOFJkL.js"
[GIN] 2024/04/04 - 10:37:22 | 200 |    1.208597ms |   192.168.215.1 | POST     "/graphql"
[GIN] 2024/04/04 - 10:37:22 | 304 |     116.251µs |   192.168.215.1 | GET      "/Inter-roman.var.woff2"
[GIN] 2024/04/04 - 10:37:22 | 304 |     130.209µs |   192.168.215.1 | GET      "/favicon-32x32.png"
[GIN] 2024/04/04 - 10:37:22 | 304 |      75.084µs |   192.168.215.1 | GET      "/site.webmanifest"
2024/04/04 10:37:38 Starting tasks processor for queue %d 1
[GIN] 2024/04/04 - 10:37:38 | 200 |    9.461647ms |   192.168.215.1 | POST     "/graphql"
2024/04/04 10:37:38 Waiting for a task
[GIN] 2024/04/04 - 10:37:38 | 200 |     333.879µs |   192.168.215.1 | POST     "/graphql"
2024/04/04 10:37:38 Command 1 added to the queue 1
[GIN] 2024/04/04 - 10:37:38 | 200 |    2.780115ms |   192.168.215.1 | POST     "/graphql"
2024/04/04 10:37:38 Processing command 1 of type input
[GIN] 2024/04/04 - 10:37:38 | 200 |    4.991847ms |   192.168.215.1 | POST     "/graphql"
[GIN] 2024/04/04 - 10:37:38 | 304 |     121.293µs |   192.168.215.1 | GET      "/assets/me-FDrf4TpF.png"
2024/04/04 10:37:40 Spawning container debian:latest "codel-terminal-1"
2024/04/04 10:37:40 Image debian:latest found locally: true
2024/04/04 10:37:40 Creating container codel-terminal-1...
2024/04/04 10:37:40 Container codel-terminal-1 created
2024/04/04 10:37:40 Container codel-terminal-1 started
2024/04/04 10:37:40 Getting next task
2024/04/04 10:37:43 Command 2 added to the queue 1
2024/04/04 10:37:43 Waiting for a task
2024/04/04 10:37:43 Processing command 2 of type browser
2024/04/04 10:37:43 Trying to get content from https://www.google.com/search?q=weather+today+in+Brighton+UK
2024/04/04 10:37:43 failed to process browser: %!w(*fmt.wrapError=&{failed to get content: Error loading page: Error resolving url: Get "http://127.0.0.1:9222/json/version": dial tcp 127.0.0.1:9222: connect: connection refused 0x40004c2520})
2024/04/04 10:37:43 Waiting for a task
[GIN] 2024/04/04 - 10:37:43 | 304 |     249.502µs |   192.168.215.1 | GET      "/assets/logo-DsABmRRe.png"

Any ideas or thoughts for a fix would be appreciated.

(base) ➜  codel docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED         STATUS         PORTS                                       NAMES
c0abd46ab9b8   debian:latest                   "tail -f /dev/null"      2 minutes ago   Up 2 minutes                                               codel-terminal-1
b55c843f5e05   ghcr.io/go-rod/rod              "dumb-init -- chrome…"   3 minutes ago   Up 3 minutes   0.0.0.0:9222->9222/tcp                      codel-browser
b5907158d8e4   ghcr.io/semanser/codel:latest   "/bin/sh -c /app"        3 minutes ago   Up 3 minutes   0.0.0.0:3000->8080/tcp, :::3000->8080/tcp   mystifying_nash

logs from "b55c843f5e05 ghcr.io/go-rod/rod" -

[0404/103646.064907:ERROR:bus.cc(406)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0404/103646.101541:ERROR:bus.cc(406)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0404/103646.101626:ERROR:bus.cc(406)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

DevTools listening on ws://0.0.0.0:9222/devtools/browser/fa303f4a-e6e0-4069-a0ce-527410575349
[0404/103646.103226:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.
[0404/103646.113222:WARNING:sandbox_linux.cc(393)] InitializeSandbox() called with multiple threads in process gpu-process.
Warning: vkCreateInstance: Found no drivers!
Warning: vkCreateInstance failed with VK_ERROR_INCOMPATIBLE_DRIVER
    at CheckVkSuccessImpl (../../third_party/dawn/src/dawn/native/vulkan/VulkanError.cpp:88)
    at CreateVkInstance (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:458)
    at Initialize (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:344)
    at Create (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:266)
    at operator() (../../third_party/dawn/src/dawn/native/vulkan/BackendVk.cpp:521)

Warning: eglChooseConfig returned zero configs
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:52)
    at Create (../../third_party/dawn/src/dawn/native/opengl/PhysicalDeviceGL.cpp:76)

@TrueNix
Copy link
Author

TrueNix commented Apr 4, 2024

What command did you use to run Codel? Did you use --network="host" by any chance? This could cause it not to work.

sudo docker run --env-file .env -p 3000:8080 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/semanser/codel:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants