cat
cat copied to clipboard
python客户端初始化失败
python客户端启动时没有解析/cat/appdatas/cat/client.xml的内容,看日志是尝试连接了本机的2280端口,配置文件的权限也是OK的,同一台机器,java客户端就没有问题
日志如下: 2020-02-27 06:02:07 PM [19408][[INFO] ] Cat log module has been successfully initialized. 2020-02-27 06:02:07 PM [19408][[INFO] ] Current hostname: xxx 2020-02-27 06:02:07 PM [19408][[INFO] ] Current ip: xxx 2020-02-27 06:02:07 PM [19408][[INFO] ] Current ip hex: xxx 2020-02-27 06:02:07 PM [19408][[DEBUG] ] Get router from server successfully 2020-02-27 06:02:07 PM [19408][[DEBUG] ] Trying connecting to the best server 2020-02-27 06:02:07 PM [19408][[INFO] ] Try connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[WARNING] ] Cannot connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[INFO] ] Try connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[WARNING] ] Cannot connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[INFO] ] Try connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[WARNING] ] Cannot connect to server 127.0.0.1:2280. 2020-02-27 06:02:07 PM [19408][[ERROR] ] Failed to initialize cat: Error occurred while getting router config from remote server. 2020-02-27 06:02:07 PM [19408][[INFO] ] Cat has been initialized with appkey: mip 2020-02-27 06:02:21 PM [19596][[INFO] ] Master process has been forked, heartbeat will be disabled.
初始化代码如下:
版本
- OS: CentOS 6.6
- python版本 3.6.4
- cat-sdk客户端版本 3.1.2
- glibc版本 2.17
同求 大神
同求大神解答 @nickevin @gfreezy @seanlinwang @atell @alcoholwang
远程配置和本地配置是什么
不清楚您(@gfreezy )说的远程配置和本地配置是啥配置,以下是我的client.xml文件配置
<?xml version="1.0" encoding="utf-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd"> <servers> <!-- Local mode for development --> <server ip="xxxxxxx.hz" port="2280" http-port="2281" /> <server ip="xxxxxxx.hz" port="2280" http-port="2281" /> </servers> </config>
<server ip="xxxxxxx.hz" port="2280" http-port="2281" /> <server ip="xxxxxxx.hz" port="2280" http-port="2281" />
这里的 IP 设置是正确的吗?
https://github.com/dianping/cat/wiki/global#%E9%85%8D%E7%BD%AE%E7%A4%BA%E4%BE%8B-1
这里我记得好像是不支持 127.0.0.1,必须要配置成网卡IP,并且与 client.xml 一致
@gfreezy 这里的IP设置应该是正确的,因为公司JAVA服务都是用的相同内容的配置文件,只是我这个是Python服务,不是Java服务。但是python的cat-sdk总是会去读127.0.0.1的IP地址;看了一圈加载clent.xml文件的源码,也没发现什么猫腻。 `>>> import cat
cat.init("beidou-api", debug=True) encoder: 1 sampling: 1 multiprocessing: 1 heartbeat: 0 Log file has been opened in write mode by other process. File: "/tmp/ccat/src/ccat/client_config.c", Line 127, in initCatClientConfig 2020-06-03 15:29:26 [28133][[INFO] ] Current hostname: beidou-dev File: "/tmp/ccat/src/ccat/message_manager.c", Line 83, in initMessageManager 2020-06-03 15:29:26 [28133][[INFO] ] Current ip: 192.168.198.200 File: "/tmp/ccat/src/ccat/message_manager.c", Line 94, in initMessageManager 2020-06-03 15:29:26 [28133][[INFO] ] Current ip hex: c0a8c6c8 Name or service not known File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 387, in updateCatServerConn 2020-06-03 15:29:26 [28133][[DEBUG] ] Get router from server successfully File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 394, in updateCatServerConn 2020-06-03 15:29:26 [28133][[DEBUG] ] Trying connecting to the best server File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 60, in tryConnBestServer 2020-06-03 15:29:26 [28133][[INFO] ] Try connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 88, in tryConnBestServer 2020-06-03 15:29:26 [28133][[WARNING] ] Cannot connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 60, in tryConnBestServer 2020-06-03 15:29:26 [28133][[INFO] ] Try connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 88, in tryConnBestServer 2020-06-03 15:29:26 [28133][[WARNING] ] Cannot connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 60, in tryConnBestServer 2020-06-03 15:29:26 [28133][[INFO] ] Try connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/server_connection_manager.c", Line 88, in tryConnBestServer 2020-06-03 15:29:26 [28133][[WARNING] ] Cannot connect to server 127.0.0.1:2280. File: "/tmp/ccat/src/ccat/client.c", Line 87, in catClientInitInner 2020-06-03 15:29:26 [28133][[ERROR] ] Failed to initialize cat: Error occurred while getting router config from remote server. File: "/tmp/ccat/src/ccat/client.c", Line 140, in catClientInitWithConfig 2020-06-03 15:29:26 [28133][[INFO] ] Cat has been initialized with appkey: beidou-api`
Hi 请问你们这个问题解决了么? 我们也遇到了相同的问题 非常感谢
已经解决了,目前pr还没人合,可以先参考下面这篇文章先用着 https://zhuanlan.zhihu.com/p/651761161
@gfreezy @dutyu @AndyWu93 @HQ1363