2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

久しぶりにBybitテスト環境APIに接続しようとしたら一日費やしてしまった話

Posted at

結論から!
APIキー作成時のIPホワイトリストに、IPを設定しないと3か月で失効します!
image.png
―― 二度と同じ人を生まないために記載しておきます

出てきたエラー1

2022-06-04 13:51:27,969 - BybitWebsocket - INFO - Authentication failed. Please check your api_key and api_secret. Topic: position

出てきたエラー2

Couldn't connect to WebSocket! Exiting.
---------------------------------------------------------------------------
WebSocketTimeoutException                 Traceback (most recent call last)
Input In [11], in <cell line: 6>()
      2 API_KEY    = 'XXX'
      3 API_SECRET = 'XXXX'
----> 6 bybitws = BybitWebsocket(wsURL="wss://stream-testnet.bybit.com/realtime",
      7                          api_key=API_KEY, api_secret=API_SECRET
      8                         )
      9 bybitws.subscribe_orderBookL2("BTCUSD")
     11 while True:

File ~\anaconda3\lib\site-packages\BybitWebsocket\__init__.py:43, in BybitWebsocket.__init__(self, wsURL, api_key, api_secret)
     40 # We can subscribe right in the connection querystring, so let's build that.
     41 # Subscribe to all pertinent endpoints
     42 self.logger.info("Connecting to %s" % wsURL)
---> 43 self.__connect(wsURL)

File ~\anaconda3\lib\site-packages\BybitWebsocket\__init__.py:74, in BybitWebsocket.__connect(self, wsURL)
     72     self.logger.error("Couldn't connect to WebSocket! Exiting.")
     73     self.exit()
---> 74     raise websocket.WebSocketTimeoutException('Error!Couldn not connect to WebSocket!.')
     76 if self.api_key and self.api_secret:
     77     self.__do_auth()

WebSocketTimeoutException: Error!Couldn not connect to WebSocket!.

ダメポイント1
本番環境のAPIキー見て、失効してないよなーとかいうチェックをしてしまう。
テスト環境のAPIキーを見よう!!

ダメポイント2
APIキーは絶対に間違ってないし、絶対に失効していない!という頭で調査し続けてしまう

ダメポイント3
ひたすら出てくるエラーについて調べてしまう
エラー「Authentication failed.」に全ての答えはでいてるようなものだった

あなたが同じようなエラーで困っていて少しでも時間の削減になればLGTM

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?