Python写数据到DolphinDB报错Couldn't send script/function to the remote host because the connection has been closed

rt,python用tableAppender向dolphindb写数据,有时候会遇到报错:

in run: Couldn't send script/function to the remote host because the connection has been closed

这个是因为数据写入太频繁 ddb拒绝连接吗?要怎么解决?

请先 登录 后评论

1 个回答

SaintM

这个问题实际上和 ask.dolphindb.net/question/2331 是同一个问题。

这个报错是说写数据的时候与dolphindb连接断开了。可能是因为网络波动造成连接断开;也可能是因为单次append的数据量较大,导致TCP传输中ack无法及时返回,然后系统会在默认时间关闭这个tcp连接。

要避免这个错误,可以调整DolphinDB Python API的两个参数:
1. 调用connect函数时,设置keepAliveTime参数。
s.connect() 这个connect函数原型是connect(host,port,[username,password, startup, highAvailability, highAvailabilitySites, keepAliveTime, reconnect])。keepAliveTime参数,主要是网络通信不稳定的情况,server服务器检测时,认为这个连接还存在,不主动关闭这个连接的时间。默认值是30秒,可以再配置大一些。

2. 调用ddb.session.setTimeout()
比如 ddb.session.setTimeout(60) 这样设置到60秒。 这个函数是用于设置数据包被发送后未接收到 ACK 确认时,TCP 连接的最大等待时长。

请先 登录 后评论