TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

Using RESTful style to execute SQL, throwing exception "Max retries exceeded with url: /rest/sql"

Open mujin-zl opened this issue 5 years ago • 1 comments

Bug Description 采用RESTful执行记录IMPORT时异常 Methods: def executeTaosSQL(sql, imei=""): AUTH = "taos:taosdata" TOKEN = str(base64.b64encode(AUTH.encode("utf-8")), "utf-8") HEADERS = { "Authorization": "Basic {}".format(TOKEN), "Content-Type": "text/xml; charset=UTF-8" } try: api = "http://172.9.168.25:6020/rest/sql" result = requests.post(url=api, headers=HEADERS, data=sql) except Exception as err: logger.exception(err) return

Python 3.6.9 Server 1.6.6.0 SQL: """IMPORT INTO bohai.g866005046238814 (ts, dt, latitude, longitude, speed, course, elev, mcc, mnc, bs, genre) USING bohai.locators TAGS('866005046238814', '{"GPS_STATE": "1", "ACC": "11", "DEFENCE_STATE": "10", "RELAY": "00", "POWER_STATE": "10", "MOVE": "11", "flag": 1, "updateTime": "2021-03-25 10:44:25"}') VALUES ('2021-03-25 10:44:24', '2021-03-25 10:44:24', 37.825587, 112.512619, 0, 203, 0, 460, 0, '{"total": 1, "baseStation": [{"mcc": 460, "mnc": 0, "lac": 13846, "ci": 48251}]}', 0);""" ERROR: HTTPConnectionPool(host='172.9.168.25', port=6020): Max retries exceeded with url: /rest/sql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f54cdf30ac8>: Failed to establish a new connection: [Errno 111] Connection refused',))

Server 2.0.12 SQL: """ IMPORT INTO bohai.g866005046239093 (ts, dt, latitude, longitude, speed, course, elev, mcc, mnc, bs, genre) USING bohai.locators TAGS('866005046239093', '{"GPS_STATE": "1", "ACC": "11", "DEFENCE_STATE": "10", "RELAY": "00", "POWER_STATE": "10", "MOVE": "11", "flag": 1, "updateTime": "2021-03-25 00:01:03", "GSM_LEVEL": "31", "GPRS": "1", "VOLTAGE": "49.4", "VBATT": "0.0", "BATTERY": "0.0", "G_SENSOR": "1", "DEFENCE_MODE": "1", "VOLTAGE_RANGE": "9-90"}') VALUES ('2021-03-25 00:01:02', '2021-03-25 00:01:02', 22.662508, 114.026736, 0, 30, 0, 460, 0, '{"total": 1, "baseStation": [{"mcc": 460, "mnc": 0, "lac": 9352, "ci": 4372}]}', 0); """ ERROR: HTTPConnectionPool(host='172.9.168.179', port=6041): Read timed out. (read timeout=5)

请问这是什么原因

mujin-zl avatar Mar 25 '21 06:03 mujin-zl

先检查下网络链接设置是否正常。

cpvmrd avatar Mar 25 '21 07:03 cpvmrd