You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/02/03 09:44:44 UTC

[GitHub] [rocketmq-client-cpp] SandyKidYao opened a new issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773883085


   > It is crazy. In my opinion, TARGET_LINK_LIBRARIES is correct way, and it is better then use CMAKE_CXX_FLAGS.
   
   While I am using other libs in my program too, it may be related to the link order between these libs.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-772942397


   Thx for reply. These are the logs I copied from the /root/logs/rocketmq-cpp folder.
   
   - 13128** is the one that generated when I run the python test code, which works fine.
   - 13390** is the one that generated by the cpp-style test code, which cannot send the msg and gets the route error.
   - 13192** is got from the c-style codes, which doesn't work either.
   
   [13390_rocketmq-cpp.log](https://github.com/apache/rocketmq-client-cpp/files/5922439/13390_rocketmq-cpp.log)
   [13128_rocketmq-cpp.log](https://github.com/apache/rocketmq-client-cpp/files/5922440/13128_rocketmq-cpp.log)
   [13192_rocketmq-cpp.log](https://github.com/apache/rocketmq-client-cpp/files/5922441/13192_rocketmq-cpp.log)
   
   BTW, when I use the cpp test codes (both cpp-style and c-style), the log from rocket mq nameserver shows that they have connected to the nameserver while the log from the broker print nothing. I guess there may be sth wrong in the connection between my cpp program and the broker. 
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] ifplusor commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773885450


   @SandyKidYao The re_dev branch is recommend to use, you can test it.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773796432






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] ifplusor commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773258700


   @SandyKidYao Can you compile cpp sdk from source?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] ifplusor commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773258700






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] ifplusor commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773812686


   It is crazy. In my opinion, TARGET_LINK_LIBRARIES is correct way, and it is better then use CMAKE_CXX_FLAGS.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao closed issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao closed issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] ifplusor commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
ifplusor commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-772379486


   @SandyKidYao Can you show more logs? or test the re_dev branch.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao commented on issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao commented on issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346#issuecomment-773796432


   I figured out what's wrong in my codes. If I link the librocketmq.so from CMake by TARGET_LINK_LIBRARIES(), the route error will happen. However, if I add the same lib (no matter installed via rpm or built from source code) through CMAKE_CXX_FLAGS, everything works fine. 
   
   THX for your time again. 
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq-client-cpp] SandyKidYao closed issue #346: No route info of this topic Error when sending msg sync in cpp, but everything normal when using the same library from python api.

Posted by GitBox <gi...@apache.org>.
SandyKidYao closed issue #346:
URL: https://github.com/apache/rocketmq-client-cpp/issues/346


   


----------------------------------------------------------------
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:
users@infra.apache.org