RFS-ADRENO / zca-js

Unofficial Zalo API for JavaScript
https://zca.tdung.co
MIT License
45 stars 27 forks source link

Error: Invalid WebSocket frame: RSV1 must be clear #10

Open nguyenhuutuananh opened 2 days ago

nguyenhuutuananh commented 2 days ago

Hello, I encountered this error message when I tried to run it. I've thoroughly researched the issue, but unfortunately, none of the solutions I've found have resolved it. Additionally, I've tried running the code on a Linux environment (Ubuntu 22.04) using Docker, but the same error persists.

Environments: Macos Sonoma 14.6.1 and Docker in Ubuntu 22.04

The error message:

INFO Logged in as 77xxxx0528xxxxx733
node:events:497
      throw er; // Unhandled 'error' event
      ^

RangeError: Invalid WebSocket frame: RSV1 must be clear
    at Receiver.getInfo (/Users/user/zalo-bot/lunch-poll-bot/node_modules/ws/lib/receiver.js:209:26)
    at Receiver.startLoop (/Users/user/zalo-bot/lunch-poll-bot/node_modules/ws/lib/receiver.js:155:16)
    at Receiver._write (/Users/user/zalo-bot/lunch-poll-bot/node_modules/ws/lib/receiver.js:94:10)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at Writable.write (node:internal/streams/writable:502:10)
    at TLSSocket.socketOnData (/Users/user/zalo-bot/lunch-poll-bot/node_modules/ws/lib/websocket.js:1355:35)
    at TLSSocket.emit (node:events:519:28)
    at Readable.read (node:internal/streams/readable:780:10)
    at Socket.read (node:net:772:39)
Emitted 'error' event on WebSocket instance at:
    at Receiver.receiverOnError (/Users/user/zalo-bot/lunch-poll-bot/node_modules/ws/lib/websocket.js:1199:15)
    at Receiver.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'WS_ERR_UNEXPECTED_RSV_1',
  [Symbol(status-code)]: 1002
}

Node.js v20.14.0

Could someone help me troubleshoot this error message?

RFS-ADRENO commented 2 days ago

Xem thử comment Có lẽ là cùng 1 vấn đề đấy.

nguyenhuutuananh commented 2 days ago

@RFS-ADRENO

Mình đã thử nhưng vẫn không được, code mình hiện tại cũng chỉ dùng từ example chứ chưa chỉnh sửa gì cả. Không biết hiện tại API có đang dùng được không nhỉ? mình đã thử một thư viện dùng Python nhưng cũng không listen message được :(

image image
RFS-ADRENO commented 2 days ago

dùng được b ơi, mình mới chạy thử hồi nãy. B cho mình xin config docker của b được k?

nguyenhuutuananh commented 2 days ago

dùng được b ơi, mình mới chạy thử hồi nãy. B cho mình xin config docker của b được k?

Đây nha bạn, cũng cơ bản chứ chưa có gì

Dockerfile

FROM node:20.17.0-alpine
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json ./

USER node
RUN npm install
COPY --chown=node:node . .

CMD [ "node", "main.js" ]

docker-compose.yml

services:
  app:
    build:
      dockerfile: Dockerfile
    environment:
      - ZALO_COOKIE=${ZALO_COOKIE}
      - ZALO_IMEI=${ZALO_IMEI}
      - ZALO_USERAGENT=${ZALO_USERAGENT}