wechaty / puppet-padlocal

Puppet PadLocal is a Pad Protocol for WeChat
https://wechaty.js.org/docs/puppet-providers/padlocal
Apache License 2.0
642 stars 88 forks source link

Cannot create room: `ERR Room create() exception: Error: roomId is required` #124

Closed willin closed 2 years ago

willin commented 2 years ago

source:

bot.on('ready', async function(){
  // sth....
  log.info(name, 'room not exists');
  log.info(name, friends);
  // 创建群组
  const newRoom = await this.Room.create(friends, name);
  await newRoom.ready();
  await newRoom.say('Hello World!');
});

error:

20:40:56 INFO 开发测试 ready
20:40:58 INFO 开发测试 allContacts
20:40:58 INFO 开发测试 room not exists
20:40:58 INFO 开发测试 Contact<XXX>,Contact<XXX>
20:40:58 ERR Room create() exception: Error: roomId is required
    at checkRequiredField (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/PadLocalClientApi.ts:9:11)
    at PadLocalClientApi.<anonymous> (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/PadLocalClientApi.ts:650:5)
    at Generator.next (<anonymous>)
    at /Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:23:12)
    at PadLocalClientApi.setChatRoomName (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:544:16)
    at PuppetPadlocal.roomCreate (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/wechaty-puppet-padlocal/src/puppet-padlocal.ts:1152:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Function.create (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/wechaty/src/user/room.ts:99:22)
Trace: Error: roomId is required
    at checkRequiredField (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/PadLocalClientApi.ts:9:11)
    at PadLocalClientApi.<anonymous> (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/PadLocalClientApi.ts:650:5)
    at Generator.next (<anonymous>)
    at /Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:23:12)
    at PadLocalClientApi.setChatRoomName (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/dist/PadLocalClientApi.js:544:16)
    at PuppetPadlocal.roomCreate (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/wechaty-puppet-padlocal/src/puppet-padlocal.ts:1152:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Function.create (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/wechaty/src/user/room.ts:99:22)
    at Wechaty.<anonymous> (/Users/v0/Projects/Authing/wechaty-authing-poc/src/downstream/ready.ts:71:13)
    at Generator.throw (<anonymous>)
    at rejected (/Users/v0/Projects/Authing/wechaty-authing-poc/src/downstream/ready.ts:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
huan commented 2 years ago

Are the friends all your friends on WeChat? Create a room requires the contacts is a bi-direction friend.

If the contacts meet the requirement, then I'd like to suggest that you can try other puppet like wxwork or paimon, and to see if other puppets work for you.

willin commented 2 years ago

yes

const friends: Contact[] = [];
const result = await Promise.allSettled(
      registeredUsers.map(async (user) => {
        const contact = await this.Friendship.search({ phone: user.phone! });
        if (contact?.friend()) {
          friends.push(contact);
        }
        return contact;
      })
    );
huan commented 2 years ago

I'm not sure whether the Friendship.search({ phone }) will work as your expected.

Have you tried to find two specific contacts by id Contact.find({ id }) so that we can make sure you get the correct contacts before creating the room?

willin commented 2 years ago

Friendship.search failed normally...

================================================================================

VError: [tid:e05dff73] request has been cancelled for reason: SERVER_ERROR: 2 UNKNOWN: [tid:e05dff73] wechat bad request error
    at Request._failAllPendingRequest (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/Request.ts:334:15)
    at ClientDuplexStreamImpl.<anonymous> (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/padlocal-client-ts/src/Request.ts:82:12)
    at ClientDuplexStreamImpl.emit (node:events:390:28)
    at ClientDuplexStreamImpl.emit (node:domain:475:12)
    at Object.onReceiveStatus (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/@grpc/grpc-js/src/client.ts:673:18)
    at Object.onReceiveStatus (/Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/@grpc/grpc-js/src/client-interceptors.ts:424:48)
    at /Users/v0/Projects/Authing/wechaty-authing-poc/node_modules/@grpc/grpc-js/src/call-stream.ts:323:24
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Jesn commented 2 years ago
07:14:57 VERB PuppetServiceImpl roomCreate()
07:14:57 ERR PuppetServiceImpl grpcError() roomCreate() rejection: roomId is required

我也遇到类似的情况了,gateway 版本0.78