gateio / gateapi-python

247 stars 92 forks source link

label: MISSING_REQUIRED_HEADER, message: Missing required header: Timestamp #59

Closed HFLeon closed 3 years ago

HFLeon commented 3 years ago

Python-SDK 4.21.2

get_order 报错

revilwang commented 3 years ago

具体怎么调用的?没有复现出类似的错误

HFLeon commented 3 years ago
    try:
        order_info = api_instance.get_order(order_id, currency_pair)
    except GateApiException as ex:
        self._l.error("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
    except ApiException as e:
        self._l.error("Exception when calling SpotApi->get_order: %s\n" % e)
HFLeon commented 3 years ago

具体是在收到socket的spot.orders通知,去获取订单信息的时候,可能比较频繁

revilwang commented 3 years ago

不是一直出现?只是偶尔触发?

from gate_api import ApiClient, Configuration, SpotApi
from gate_api.exceptions import GateApiException

def main():
    config = Configuration(key='<your key>', secret='<your secret>')
    spot_api = SpotApi(ApiClient(config))
    order = spot_api.get_order('<real-id>', 'GT_USDT')
    print(order.id)
    try:
        order = spot_api.get_order('<fake-id>', 'GT_USDT')
        print(order.id)
    except GateApiException as ex:
        print(ex.label, ex.message)

if __name__ == '__main__':
    main()

我试着用这个最小代码片段调用是正常的

HFLeon commented 3 years ago

其中有几次是正常的,有几次就报这错

在 2021年6月17日,19:22,revilwang @.***> 写道:

 不是一直出现?只是偶尔触发?

from gate_api import ApiClient, Configuration, SpotApi from gate_api.exceptions import GateApiException

def main(): config = Configuration(key='', secret='') spot_api = SpotApi(ApiClient(config)) order = spot_api.get_order('', 'GT_USDT') print(order.id) try: order = spot_api.get_order('', 'GT_USDT') print(order.id) except GateApiException as ex: print(ex.label, ex.message)

if name == 'main': main() 我试着用这个最小代码片段调用是正常的

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

revilwang commented 3 years ago

猜测是不是有多线程 SpotApi 实例混用的情况,如果你配置的 SpotApi 没有配置 keysecret 就会按照公共接口来处理不做任何请求加密,访问私有接口的时候就会被认证拒绝。比如下面这种方式是会报无效请求头的错误

spot_api = SpotApi(ApiClient(Configuration()))
order = spot_api.get_order('<real-id>', 'GT_USDT')