fulln opened a new issue, #1125:
URL: https://github.com/apache/rocketmq-clients/issues/1125

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq-clients/discussions).
   
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq-clients/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq-clients/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Programming Language of the Client
   
   Node.js
   
   ### Runtime Platform Environment
   
   使用官方的示例,消费一直提示序列化失败:
   13 INTERNAL: Request message serialization failure: Assertion failed
   
   
   
   ### RocketMQ Version of the Client/Server
   
   5.1.4
   
   ### Run or Compiler Version
   
   docker上运行的
   
   docker启动的,compose 如下所示
   
   ```
   version: "3.8"
   
   services:
     rmqnamesrv:
       image: apache/rocketmq:5.1.4
       container_name: rmqnamesrv
       network_mode: host
       environment:
         JAVA_OPT_EXT: "-Xms512m -Xmx512m"
       command: sh mqnamesrv
       restart: unless-stopped
   
     rmqbroker:
       image: apache/rocketmq:5.1.4
       container_name: rmqbroker
       network_mode: host
       environment:
         JAVA_OPT_EXT: "-Xms1g -Xmx1g"
       command: sh mqbroker -c /home/rocketmq/broker.conf
       volumes:
         - /home/ubuntu/rocketmq/broker.conf:/home/rocketmq/broker.conf
         - /home/ubuntu/rocketmq/store:/home/rocketmq/store
         - /home/ubuntu/rocketmq/logs:/home/rocketmq/logs
       depends_on:
         - rmqnamesrv
       restart: unless-stopped
   
     rmqproxy:
       image: apache/rocketmq:5.1.4
       container_name: rmqproxy
       network_mode: host
       environment:
         JAVA_OPT_EXT: "-Xms512m -Xmx512m"
       command: sh mqproxy -pc /home/rocketmq/rmqproxy.json
       volumes:
         - /home/ubuntu/rocketmq/rmqproxy.json:/home/rocketmq/rmqproxy.json
       depends_on:
         - rmqbroker
       restart: unless-stopped
   
     rmqconsole:
       image: apacherocketmq/rocketmq-dashboard:latest
       container_name: rmqconsole
       network_mode: host
       environment:
         JAVA_OPTS: "-Drocketmq.namesrv.addr=127.0.0.1:9876 -Dserver.port=8080"
       depends_on:
         - rmqnamesrv
         - rmqbroker
       restart: unless-stopped
   ```
   
   
   
   ### Describe the Bug
   
   使用官方的示例,消费一直提示序列化失败:
   13 INTERNAL: Request message serialization failure: Assertion failed
   
   
   ### Steps to Reproduce
   
   /**
    * RocketMQ Full Test - Producer + Consumer
    * 确保消费者先启动,然后发送消息
    */
   
   import { Producer, SimpleConsumer, Message } from 'rocketmq-client-nodejs';
   
   const ENDPOINTS = 'localhost:8081';
   const TOPIC = 'test-demo';
   const CONSUMER_GROUP = 'test-consumer-' + Date.now(); // 使用唯一的消费者组
   
   function parseMessageBody(body: string | undefined): void {
     if (!body) return;
     
     try {
       const parsed = JSON.parse(body);
       console.log('  Parsed:', JSON.stringify(parsed, null, 2));
     } catch (_e) {
       // ignore parse errors
     }
   }
   
   async function testProducerConsumer() {
     console.log('='.repeat(60));
     console.log('🚀 RocketMQ 完整测试开始');
     console.log('='.repeat(60));
     console.log('Endpoints:', ENDPOINTS);
     console.log('Topic:', TOPIC);
     console.log('Consumer Group:', CONSUMER_GROUP);
     console.log('');
   
     // 1. 先启动消费者
     console.log('📥 步骤 1: 启动消费者...');
     const consumer = new SimpleConsumer({
       endpoints: ENDPOINTS,
       consumerGroup: CONSUMER_GROUP,
       namespace: '',
       subscriptions: new Map([[TOPIC, '*']]),
     });
   
     await consumer.startup();
     console.log('✅ 消费者启动成功\n');
   
     // 等待消费者完全就绪
     await new Promise(resolve => setTimeout(resolve, 2000));
   
     // 2. 发送测试消息
     console.log('📤 步骤 2: 发送测试消息...');
     const producer = new Producer({
       endpoints: ENDPOINTS,
       namespace: '',
     });
   
     await producer.startup();
     console.log('✅ 生产者启动成功');
   
     const testMessage = {
       timestamp: new Date().toISOString(),
       message: '这是一条测试消息',
       testId: Math.random().toString(36).substring(7),
     };
   
     const message = new Message({
       topic: TOPIC,
       body: Buffer.from(JSON.stringify(testMessage)),
     });
   
     const sendResult = await producer.send(message);
     console.log('✅ 消息发送成功');
     console.log('   Message ID:', sendResult.messageId);
     console.log('   Message Content:', testMessage);
     console.log('');
   
     await producer.shutdown();
   
     // 3. 等待并接收消息
     console.log('📥 步骤 3: 接收消息...');
     console.log('等待消息到达...\n');
   
     let received = false;
     const maxAttempts = 10;
   
     for (let i = 1; i <= maxAttempts; i++) {
       console.log(`[${i}/${maxAttempts}] 尝试接收消息...`);
       
       try {
         // 每次等待 10 秒
         const messages = await consumer.receive(10, 10);
         
         if (messages.length > 0) {
           console.log(`\n🎉 成功接收 ${messages.length} 条消息!`);
           console.log('='.repeat(60));
           
           for (const msg of messages) {
             const body = msg.body?.toString('utf-8');
             console.log('\n消息详情:');
             console.log('  Message ID:', msg.messageId);
             console.log('  Topic:', msg.topic);
             console.log('  Body:', body);
             
             parseMessageBody(body);
             
             await consumer.ack(msg);
             console.log('  ✅ 已确认消息');
           }
           
           received = true;
           break;
         } else {
           console.log('   ⏳ 暂无消息');
         }
       } catch (error: unknown) {
         const errorMessage = error instanceof Error ? error.message : 
String(error);
         console.error(`   ❌ 接收失败:`, errorMessage);
       }
       
       if (i < maxAttempts) {
         await new Promise(resolve => setTimeout(resolve, 1000));
       }
     }
   
     await consumer.shutdown();
     console.log('\n✅ 消费者已关闭');
   
     console.log('\n' + '='.repeat(60));
     if (received) {
       console.log('✅ 测试成功!消息发送和接收都正常工作');
     } else {
       console.log('❌ 测试失败:消息发送成功但未能接收到');
       console.log('');
       console.log('可能的原因:');
       console.log('1. Broker 和 Consumer 之间的网络连接问题');
       console.log('2. Topic 配置问题(权限、分区等)');
       console.log('3. RocketMQ Proxy 配置问题');
     }
     console.log('='.repeat(60));
   }
   
   testProducerConsumer().catch(console.error);
   
   
   ### What Did You Expect to See?
   
   正常的消费组进行消费
   
   ### What Did You See Instead?
   
   13 INTERNAL: Request message serialization failure: Assertion failed
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to