首页 文章

潮流数据库,一些写操作后的连接错误

提问于
浏览
0

我尝试使用InfluxDB来保存一些监视器数据 . 我使用默认配置启动了InfluxDB,并使用python通过我自己的mac中的HTTP API编写一些测试数据,一切顺利 . 但是每次写完一些数据后我都遇到了一个ConnectionError . 我的测试代码是

for event_id in xrange(0, 100000):
    requests.post("http://127.0.0.1:8086/write?db=mydb", data="test_a,event={0} value=100 1538841600000000000".format(event_id))

执行约16300次后,将报告错误 .

HTTPConnectionPool(host='127.0.0.1', port=8086): Max retries exceeded with url: /write?db=mydb (Caused by NewConnectionError("<urllib3.connection.HTTPConnection object at 0x110a5fb10>: Failed to establish a new connection: [Errno 49] Can't assign requested address",)

然后,我应该在写入新数据之前等待大约2秒钟 .

我的操作系统是MacOS 10.14,所有数据都保存在HDD硬盘中 .

潮流版本是vv1.6.4(git:master c75cdfdfa6f71a08473fefcec71f6cbcbdef1ff4)

潮流数据库做了一些整理吗?

1 回答

  • 0

    好的,我找到了原因,因为这个API是HTTP协议并且请求使用TCP连接发送HTTP请求,所以每次请求完成后,TCP连接都没有关闭,它会转到TIME_WAIT并在关闭前等待超时 . 所以我操作系统的端口资源已经耗尽......

相关问题