SandyKidYao opened a new issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346


   The msg producer works with python api but not working in cpp. The error msg 
is "No route info of this topic: ".
   
   In fact the python api is rely on the cpp client, and it works fine while 
the cpp codes don't, I hope someone can give a little help with my problem ( I 
run the example and got the similar error).
   
   - OS: centos 7 (docker image from the official centos, tag 7.9.2009)
   - RocketMQ version: 4.7.1(built and installed from the source code with 
maven, the JAVA_OPT in runserver.sh and runbroker.sh are modified like 
"-Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m")
   - rocketmq-client-cpp version : 2.0.0 and 2.2.0, installed via the rpm pkg 
got from the release page
   - rocketmq-client-python version : 2.0.0, installed via pip
   
   The test code (c-style) in cpp like below
   ```cpp
   int main(int argc, const char *argv[]) {
       CProducer* producer = CreateProducer("Group_producer");
       SetProducerNameServerAddress(producer, "127.0.0.1:9876");
       StartProducer(producer);
       CMessage* msg = CreateMessage("T_TestTopic");
       std::string body = "hello";
       SetMessageBody(msg, body.c_str());
       CSendResult result;
       int status = SendMessageSync(producer, msg, &result);
       if (status == OK) {
           std::cout<<"send msg success " <<result.msgId << " "  << 
result.offset <<" " << (int)result.sendStatus<<std::endl;
   
       } else {
           std::cout<<"send msg failed"<<std::endl;
       }
       ShutdownProducer(producer);
       DestroyProducer(producer);
   }
   ```
   And the cpp-style test code 
   ```cpp
   #include<rocketmq/DefaultMQProducer.h>
   
   int main(int argc, const char *argv[]) {
   
       rocketmq::DefaultMQProducer producer("please_rename_unique_group_name");
       producer.setNamesrvAddr("127.0.0.1:9876");
       producer.start();
       rocketmq::MQMessage msg("channel_test", "{\"channel\": 
\"channel_001\"}");
       producer.send(msg);
       producer.shutdown();
   
   }
   ```
   
   The test code in python works fine, like this.
   ```python
   from rocketmq.client import Producer, Message
   
   producer = Producer('PID-XXX')
   producer.set_name_server_address(HOST)
   producer.start()
   msg = Message(TOPIC)
   msg.set_body("hello")
   ret = producer.send_sync(msg)
   print(ret.status, ret.msg_id, ret.offset)
   producer.shutdown()
   ```
   
   The logs generated by cpp codes are a little different from the ones by 
python code. There are lots of warnings. I tried to figure out what happened 
but got noting valuable.
   
   ```log
   [2021-Feb-03 09:00:20.043586](warning):waitResponse of code:105 with 
opaque:8 timeout[waitResponse:61]
   [2021-Feb-03 09:00:20.043956](warning):wait response timeout or get NULL 
response of code:105, so closeTransport of addr:[invokeSync:217]
   [2021-Feb-03 09:00:20.044166](warning):closeTransport: 
disconnect:127.0.0.1:9876 with state:2[CloseTransport:429]
   [2021-Feb-03 09:00:20.044593](warning):closeTransport: erase broker: 
127.0.0.1:9876[CloseTransport:432]
   [2021-Feb-03 09:00:20.044931](warning):Get topic[T_TestTopic] route failed 
[Null Response].[getTopicRouteInfoFromNameServer:338]
   [2021-Feb-03 09:00:25.047442](warning):waitResponse of code:105 with 
opaque:9 timeout[waitResponse:61]
   [2021-Feb-03 09:00:25.047591](warning):wait response timeout or get NULL 
response of code:105, so closeTransport of addr:[invokeSync:217]
   [2021-Feb-03 09:00:25.047664](warning):closeTransport: 
disconnect:127.0.0.1:9876 with state:2[CloseTransport:429]
   [2021-Feb-03 09:00:25.047908](warning):closeTransport: erase broker: 
127.0.0.1:9876[CloseTransport:432]
   [2021-Feb-03 09:00:25.048088](warning):Get topic[TBW102] route failed [Null 
Response].[getTopicRouteInfoFromNameServer:338]
   [2021-Feb-03 09:00:25.048147](warning):tryToFindTopicPublishInfo 
null:T_TestTopic[tryToFindTopicPublishInfo:155]
   [2021-Feb-03 09:00:25.048178](warning):Retry many times, still 
failed[sendDefaultImpl:431]
   [2021-Feb-03 09:00:30.049733](warning):waitResponse of code:105 with 
opaque:10 timeout[waitResponse:61]
   [2021-Feb-03 09:00:30.049868](warning):wait response timeout or get NULL 
response of code:105, so closeTransport of addr:[invokeSync:217]
   [2021-Feb-03 09:00:30.049935](warning):closeTransport: 
disconnect:127.0.0.1:9876 with state:2[CloseTransport:429]
   [2021-Feb-03 09:00:30.050166](warning):closeTransport: erase broker: 
127.0.0.1:9876[CloseTransport:432]
   [2021-Feb-03 09:00:30.050240](warning):Get topic[T_TestTopic] route failed 
[Null Response].[getTopicRouteInfoFromNameServer:338]
   [2021-Feb-03 09:00:35.029496](warning):sendheartbeat brokeradd is 
empty[sendHeartbeatToAllBroker:772]
   [2021-Feb-03 09:00:35.051976](warning):waitResponse of code:105 with 
opaque:11 timeout[waitResponse:61]
   [2021-Feb-03 09:00:35.052085](warning):wait response timeout or get NULL 
response of code:105, so closeTransport of addr:[invokeSync:217]
   [2021-Feb-03 09:00:35.052151](warning):closeTransport: 
disconnect:127.0.0.1:9876 with state:2[CloseTransport:429]
   [2021-Feb-03 09:00:35.052344](warning):closeTransport: erase broker: 
127.0.0.1:9876[CloseTransport:432]
   [2021-Feb-03 09:00:35.052410](warning):Get topic[TBW102] route failed [Null 
Response].[getTopicRouteInfoFromNameServer:338]
   [2021-Feb-03 09:00:35.052447](warning):tryToFindTopicPublishInfo 
null:T_TestTopic[tryToFindTopicPublishInfo:155]
   [2021-Feb-03 09:00:35.052475](warning):Retry many times, still 
failed[sendDefaultImpl:431]
   
   ```
   
   
   
   
   
   
   
   
   


----------------------------------------------------------------
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.

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


Reply via email to