📝 openclaw agents add main. openclaw gateway run

AI
編輯檔案 返回列表

Gateway 其實已經在跑了(pid 13560)!只是排程工作啟動需要一點時間。

直接試試:

 
 
powershell
openclaw tui
 
 
 
 
 

You said: PS C:\Users\wu> openclaw tui

PS C:\Users\wu> openclaw tui 🦞 OpenClaw 2026.4.27 (cbc2ba0) — Your second brain, except this one actually remembers where you left things. openclaw tui - ws://127.0.0.1:18789 - agent main - session main connecting | idle agent main | session main | unknown | tokens ? ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

4月30日
 
 
 
 
 

Claude responded: 正在連線中,稍等幾秒看看狀態會不會變成 connected。

正在連線中,稍等幾秒看看狀態會不會變成 connected

如果還是卡住或斷線,把畫面貼過來!

 
 
 
 
 

You said: 🦞 OpenClaw 2026.

🦞 OpenClaw 2026.4.29 (a448042) — I can run local, remote, or purely on vibes—results may vary with DNS. | o 14:59:13 [gateway] loading configuration… 14:59:36 [gateway] resolving authentication… 14:59:36 [gateway] starting... 15:00:37 [gateway] starting HTTP server... 15:00:40 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/ (root C:\Users\wu\.openclaw\canvas) 15:01:00 [tasks/registry] Failed to restore task registry 15:01:16 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s) 15:01:29 [diagnostic] liveness warning: reasons=event_loop_delay,event_loop_utilization interval=57s eventLoopDelayP99Ms=48687.5 eventLoopDelayMaxMs=48687.5 eventLoopUtilization=0.991 cpuCoreRatio=0.051 active=0 waiting=0 queued=0 15:01:29 [gateway] agent model: openai/gpt-5.5 15:01:29 [gateway] http server listening (0 plugins, 112.1s) 15:01:29 [gateway] log file: C:\Users\wu\AppData\Local\Temp\openclaw\openclaw-2026-05-01.log 15:01:29 [gateway] starting channels and sidecars... 15:01:31 [gateway] ready 15:01:31 [heartbeat] started 15:03:29 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=161.9 eventLoopDelayMaxMs=3961.5 eventLoopUtilization=0.141 cpuCoreRatio=0.031 active=0 waiting=0 queued=0

 
下午3:05
 
 
 
 
 

Claude responded: 🎉 Gateway 成功啟動了!

🎉 Gateway 成功啟動了!

從日誌可以看到:

  • gateway ready
  • ✅ HTTP server 正在監聽
  • ✅ Agent model:openai/gpt-5.5
  • ✅ Heartbeat 已啟動

現在去 TUI 視窗,應該已經顯示 connected 了。可以開始使用 OpenClaw 了!

有什麼需要進一步設定或使用上的問題,隨時告訴我 🦞

 
 
 
 
 

You said: TUI 視窗是那個?

TUI 視窗是那個?

下午3:07
 
 
 
 
 

Claude responded: 你需要另外開一個 PowerShell 視窗來執行 TUI,因為目前這個視窗已經被 gateway 佔用了。

你需要另外開一個 PowerShell 視窗來執行 TUI,因為目前這個視窗已經被 gateway 佔用了。

開新的 PowerShell 視窗,然後執行:

 
 
powershell
openclaw tui
 
 
 
 
 

You said: PS C:\Users\wu> openclaw tui

PS C:\Users\wu> openclaw tui 🦞 OpenClaw 2026.4.29 (a448042) — We ship features faster than Apple ships calculator updates. openclaw tui - ws://127.0.0.1:18789 - agent main - session main connecting | idle agent main | session main | unknown | tokens ?

下午3:08
 
 
 
 
 

Claude responded: 還在連線中,稍等幾秒看看狀態是否變成 connected。

還在連線中,稍等幾秒看看狀態是否變成 connected

如果一直卡在 connecting,回到跑 gateway 的那個視窗,看看有沒有新的錯誤訊息出現,把內容貼過來!

 
 
 
 
 

You said: OpenClaw 2026.

OpenClaw 2026.4.29 (a448042) — I can run local, remote, or purely on vibes—results may vary with DNS. | o 14:59:13 [gateway] loading configuration… 14:59:36 [gateway] resolving authentication… 14:59:36 [gateway] starting... 15:00:37 [gateway] starting HTTP server... 15:00:40 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/ (root C:\Users\wu\.openclaw\canvas) 15:01:00 [tasks/registry] Failed to restore task registry 15:01:16 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s) 15:01:29 [diagnostic] liveness warning: reasons=event_loop_delay,event_loop_utilization interval=57s eventLoopDelayP99Ms=48687.5 eventLoopDelayMaxMs=48687.5 eventLoopUtilization=0.991 cpuCoreRatio=0.051 active=0 waiting=0 queued=0 15:01:29 [gateway] agent model: openai/gpt-5.5 15:01:29 [gateway] http server listening (0 plugins, 112.1s) 15:01:29 [gateway] log file: C:\Users\wu\AppData\Local\Temp\openclaw\openclaw-2026-05-01.log 15:01:29 [gateway] starting channels and sidecars... 15:01:31 [gateway] ready 15:01:31 [heartbeat] started 15:03:29 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=161.9 eventLoopDelayMaxMs=3961.5 eventLoopUtilization=0.141 cpuCoreRatio=0.031 active=0 waiting=0 queued=0 15:08:11 [ws] handshake timeout conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 15:08:41 [ws] closed before connect conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1006 reason=n/a

 
下午3:09
 
 
 
 
 

Claude responded: 找到問題了!日誌顯示 handshake timeout,TUI 連線時 WebSocket 握手超時——原因是 gateway token 沒有傳給 TUI。

找到問題了!日誌顯示 handshake timeout,TUI 連線時 WebSocket 握手超時——原因是 gateway token 沒有傳給 TUI

試試帶 token 直接連線:

 
 
powershell
openclaw tui --token 274cf80c6737b669181eff72acb4bf51d5e3feb1726572d8
 
 
 
 
 

You said: 14:59:13 [gateway] loading configuration…

14:59:13 [gateway] loading configuration… 14:59:36 [gateway] resolving authentication… 14:59:36 [gateway] starting... 15:00:37 [gateway] starting HTTP server... 15:00:40 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/ (root C:\Users\wu\.openclaw\canvas) 15:01:00 [tasks/registry] Failed to restore task registry 15:01:16 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s) 15:01:29 [diagnostic] liveness warning: reasons=event_loop_delay,event_loop_utilization interval=57s eventLoopDelayP99Ms=48687.5 eventLoopDelayMaxMs=48687.5 eventLoopUtilization=0.991 cpuCoreRatio=0.051 active=0 waiting=0 queued=0 15:01:29 [gateway] agent model: openai/gpt-5.5 15:01:29 [gateway] http server listening (0 plugins, 112.1s) 15:01:29 [gateway] log file: C:\Users\wu\AppData\Local\Temp\openclaw\openclaw-2026-05-01.log 15:01:29 [gateway] starting channels and sidecars... 15:01:31 [gateway] ready 15:01:31 [heartbeat] started 15:03:29 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=161.9 eventLoopDelayMaxMs=3961.5 eventLoopUtilization=0.141 cpuCoreRatio=0.031 active=0 waiting=0 queued=0 15:08:11 [ws] handshake timeout conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 15:08:41 [ws] closed before connect conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1006 reason=n/a 15:10:39 [ws] handshake timeout conn=d7d12006-0335-449f-9347-1e556a3c5941 peer=127.0.0.1:54425->127.0.0.1:18789 remote=127.0.0.1 15:10:59 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=568.3 eventLoopDelayMaxMs=1514.1 eventLoopUtilization=0.11 cpuCoreRatio=0.001 active=0 waiting=0 queued=0

 
下午3:11
 
 
 
 
 

Claude responded: 還是 handshake timeout,token 沒有成功傳遞。

還是 handshake timeout,token 沒有成功傳遞。

來把 token 設定到這個 session 的環境變數,然後再試:

 
 
powershell
$env:OPENCLAW_GATEWAY_TOKEN = "274cf80c6737b669181eff72acb4bf51d5e3feb1726572d8"
openclaw tui
 
 
 
 
 

You said: 🦞 OpenClaw 2026.

🦞 OpenClaw 2026.4.29 (a448042) — I can run local, remote, or purely on vibes—results may vary with DNS. | o 14:59:13 [gateway] loading configuration… 14:59:36 [gateway] resolving authentication… 14:59:36 [gateway] starting... 15:00:37 [gateway] starting HTTP server... 15:00:40 [canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/ (root C:\Users\wu\.openclaw\canvas) 15:01:00 [tasks/registry] Failed to restore task registry 15:01:16 [health-monitor] started (interval: 300s, startup-grace: 60s, channel-connect-grace: 120s) 15:01:29 [diagnostic] liveness warning: reasons=event_loop_delay,event_loop_utilization interval=57s eventLoopDelayP99Ms=48687.5 eventLoopDelayMaxMs=48687.5 eventLoopUtilization=0.991 cpuCoreRatio=0.051 active=0 waiting=0 queued=0 15:01:29 [gateway] agent model: openai/gpt-5.5 15:01:29 [gateway] http server listening (0 plugins, 112.1s) 15:01:29 [gateway] log file: C:\Users\wu\AppData\Local\Temp\openclaw\openclaw-2026-05-01.log 15:01:29 [gateway] starting channels and sidecars... 15:01:31 [gateway] ready 15:01:31 [heartbeat] started 15:03:29 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=161.9 eventLoopDelayMaxMs=3961.5 eventLoopUtilization=0.141 cpuCoreRatio=0.031 active=0 waiting=0 queued=0 15:08:11 [ws] handshake timeout conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 15:08:41 [ws] closed before connect conn=65c612cf-9bb5-45cf-967e-268548845e08 peer=127.0.0.1:54424->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1006 reason=n/a 15:10:39 [ws] handshake timeout conn=d7d12006-0335-449f-9347-1e556a3c5941 peer=127.0.0.1:54425->127.0.0.1:18789 remote=127.0.0.1 15:10:59 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=568.3 eventLoopDelayMaxMs=1514.1 eventLoopUtilization=0.11 cpuCoreRatio=0.001 active=0 waiting=0 queued=0 15:11:22 [ws] closed before connect conn=d7d12006-0335-449f-9347-1e556a3c5941 peer=127.0.0.1:54425->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1006 reason=n/a 15:12:29 [ws] handshake timeout conn=c4aa67f3-9011-4e70-bab6-34f2ff2b765c peer=127.0.0.1:54445->127.0.0.1:18789 remote=127.0.0.1

 
下午3:13
 
 
 
 
 

Claude responded: 注意到一個關鍵問題:你貼的還是 gateway 視窗的日誌,TUI 視窗那邊的畫面是什麼?

注意到一個關鍵問題:你貼的還是 gateway 視窗的日誌,TUI 視窗那邊的畫面是什麼?

另外,日誌裡的 handshake timeout 持續發生,懷疑是 gateway 的 event loop 太忙(之前有出現 eventLoopUtilization=0.991)導致無法及時處理連線。

試試重啟 gateway

在 gateway 視窗按 Ctrl+C 停止,然後重新執行:

 
 
powershell
openclaw gateway run

等到出現 [gateway] ready 後,馬上在另一個視窗執行:

 
 
powershell
$env:OPENCLAW_GATEWAY_TOKEN = "274cf80c6737b669181eff72acb4bf51d5e3feb1726572d8"
openclaw tui
 
 
 
 
 

You said: PS C:\Users\wu> openclaw tui

PS C:\Users\wu> openclaw tui 🦞 OpenClaw 2026.4.29 (a448042) — Your .zshrc wishes it could do what I do. openclaw tui - ws://127.0.0.1:18789 - agent main - session main connecting | idle agent main | session main | unknown | tokens ?

下午3:13
 
 
 
 
 

Claude responded: 稍等幾秒,看看狀態會不會從 connecting 變成 connected。

稍等幾秒,看看狀態會不會從 connecting 變成 connected

同時在 gateway 視窗觀察有沒有新的日誌出現。把兩個視窗的狀態都貼過來!

 
 
 
 
 

You said: 27.

27.0.0.1 15:12:59 [ws] closed before connect conn=c4aa67f3-9011-4e70-bab6-34f2ff2b765c peer=127.0.0.1:54445->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1006 reason=n/a 15:13:29 [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=293.6 eventLoopDelayMaxMs=2237.7 eventLoopUtilization=0.076 cpuCoreRatio=0.037 active=0 waiting=0 queued=0

下午3:14
 
 
 
 
 

Claude responded: 問題很明顯:每次連線都是 closed before connect,而且沒有任何認證相關的日誌——代表 token 驗證根本沒到那一步就斷了。

問題很明顯:每次連線都是 closed before connect,而且沒有任何認證相關的日誌——代表 token 驗證根本沒到那一步就斷了。

試試直接用 HTTP 測試 gateway 是否正常回應

在新的 PowerShell 視窗執行:

 
 
powershell
Invoke-WebRequest -Uri "http://127.0.0.1:18789/" -UseBasicParsing

把輸出貼過來,看看 gateway 的 HTTP 端是否正常運作!

 
 
 
 
 

You said: PS C:\Users\wu> Invoke-WebRequest -Uri "http://127.

PS C:\Users\wu> Invoke-WebRequest -Uri "http://127.0.0.1:18789/" -UseBasicParsing StatusCode : 200 StatusDescription : OK Content : <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>OpenClaw Control</title> <meta name="... RawContent : HTTP/1.1 200 OK X-Content-Type-Options: nosniff Referrer-Policy: no-referrer Permissions-Policy: camera=(), microphone=(self), geolocation=() X-Frame-Options: DENY Content-Security-Policy: defaul... Forms : Headers : {[X-Content-Type-Options, nosniff], [Referrer-Policy, no-referrer], [Permissions-Policy, camera=(), microphone=(self), geolocation=()], [X-Frame-Options, DENY]...} Images : {} InputFields : {} Links : {} ParsedHtml : RawContentLength : 2801

 
下午3:15
 
 
 
 
 

Claude responded: HTTP 正常!Gateway 有在跑。問題出在 WebSocket 連線階段。

HTTP 正常!Gateway 有在跑。問題出在 WebSocket 連線階段。

試試用瀏覽器開啟 Dashboard,看看能不能從網頁介面操作:

 
 
http://127.0.0.1:18789/

直接在瀏覽器貼上這個網址,看看出現什麼畫面!

 
 
 
 
 
下午3:17
 
 
 
 
 

Claude responded: 找到問題了!網頁顯示 unauthorized: gateway token missing,需要在網頁介面輸入 token 才能連線。

找到問題了!網頁顯示 unauthorized: gateway token missing,需要在網頁介面輸入 token 才能連線。

網關令牌欄位輸入:

 
 
274cf80c6737b669181eff72acb4bf51d5e3feb1726572d8

然後按連接按鈕,看看能不能成功連線!

 
 
 
 
 
下午3:18
 
 
 
 
 

Claude responded: 🎉 成功了!OpenClaw 已經正常運作!

🎉 成功了!OpenClaw 已經正常運作!

畫面顯示:

  • Ready to chat
  • ✅ 連線到 gpt-5.5 · openai
  • ✅ 版本 v2026.4.29

你現在可以直接在瀏覽器介面使用 OpenClaw 了!網址是 http://127.0.0.1:18789/chat?session=main,之後要用的話直接開這個網址就好。

如果之後想讓 TUI 也能正常連線,可以執行:

 
 
powershell
openclaw dashboard

這個指令會自動帶 token 開啟瀏覽器,不需要每次手動輸入 token。