【问题标题】:How to subscribe data using DolphinDB Python API?如何使用 DolphinDB Python API 订阅数据?
【发布时间】:2019-10-31 10:00:11
【问题描述】:

我想从 DolphinDB 订阅数据,我已经在 DolphinDB 中运行了这些代码:

share streamTable(10000:0,`time`sym`price`id, [TIMESTAMP,SYMBOL,DOUBLE,INT]) as trades
setStreamTableFilterColumn(trades, `sym)
insert into trades values(take(now(), 10), rand(`ab`cd`ef`gh`ij, 10), rand(1000,10)/10.0, 1..10)

以及 Python 中的这些代码:

import dolphindb as ddb
import numpy as np
s = ddb.session()
s.enableStreaming(8000)

def handler(lst):         
    print(lst)

s.subscribe("localhost",8848,handler,"trades","action",0,False,np.array(['ab']))

我遇到了这个错误:

ERROR in subscribeInternal err: The feature of publish is not enabled.
Retry subscribe in 1 second
ERROR in subscribeInternal err: The feature of publish is not enabled.
Retry subscribe in 1 second
ERROR in subscribeInternal err: The feature of publish is not enabled.
Retry subscribe in 1 second

那么如何开启发布功能呢?

【问题讨论】:

    标签: python database api streaming dolphindb


    【解决方案1】:

    python 代码看起来不错。不过

    1) 您可能会仔细检查您是否设置了参数 maxPubConnection,如下所示。为了启用发布,必须在服务器端设置此参数。 maxPubConnection=256

    2) 对于稳健订阅,建议使用“127.0.0.1”等ip地址而不是“localhost”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-25
      • 1970-01-01
      • 2016-02-19
      • 2020-02-26
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      • 1970-01-01
      相关资源
      最近更新 更多