demo code not work
larvata opened this issue · comments
Larvata commented
steps to reproduce:
nodejs: v11.15.0, v12.11.1
- start cqhttp container
docker run -ti --rm --name cqhttp-test \
-v $(pwd)/data:/home/user/coolq \
-p 9000:9000 \
-p 9001:9001 \
-p 5700:5700 \
-e COOLQ_ACCOUNT=<my_qq_id> \
-e CQHTTP_SERVE_DATA_FILES=yes \
-e VNC_PASSWD=12345678 \
richardchien/cqhttp:latest
-
login in noVNC
-
update echobot.js L:23
const CQWebsocket = require('../')
-->
const CQWebsocket = require('../').default
- run
node echobot.js --port 9001
console output:
[/event] 建立連線中, 請稍後...
[/api] 建立連線中, 請稍後...
[/event] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
container output:
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Path: '/event'
172.17.0.1 - - [07/Oct/2019 20:06:00] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:00] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Path: '/event'
172.17.0.1 - - [07/Oct/2019 20:06:06] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:06] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:07] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:07] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:07] connecting to: 127.0.0.1:5911
牛牛 commented
Make sure to enable websocket server by CQHTTP via use_ws
(which is false
by default) and the default port of websocket server is on port 6700 so you should also modify your port forwarding.
Larvata commented
After following your instructions, it works, thank you.