ERROR - WebSocket Non-Authenticated encountered error:

annamatdata
Posts: 1
Joined: Mon Oct 23, 2023 12:00 am

ERROR - WebSocket Non-Authenticated encountered error:

Post by annamatdata » Mon Oct 23, 2023 12:08 am

0

Hello!

I'm getting the following error when trying to connect to ByBit via websocket: 'pybit - ERROR - WebSocket Non-Authenticated encountered error: [Errno 11001] getaddrinfo failed.'

I use this Python code:

https://bybit-exchange.github.io/docs/inverse/
"""
# API imports
from pybit import HTTP
from pybit import WebSocket

#configuration variables
mode = 'test'
timeframe = 60
kline_limit = 200
#tells the api what is the maximum number of data size I want you to pull when getting historical candle sticks
z_score_window = 21
#LIVE API
api_key_mainnet = " "
api_secret_mainnet = " "

#TEST API
api_key_testnet = "MiOssurfyegxj739Lb"
api_secret_testnet = "c8C7BDKJZEWn5CDaUcTtIQzTqktd4HPqd4uL"

#SELECTED API
if mode == 'test':
 api_key = api_key_testnet
else:
 api_key = api_key_mainnet
if mode == 'test':
 api_secret = api_secret_testnet
else:
 api_secret = api_secret_mainnet

#SELECTED URL
if mode == "test":
 api_url = "https://api-testnet.bybit.com"
else:
 "https://api.bybit.com"

# SESSION Activation
session = HTTP(api_url)

# Web Socket Connection

subs = [
"candle.1.BTCUSDT"
]
ws = WebSocket(
"wss://stream-testnet.bybit.com/v5/public/linear",
subscriptions=subs
)

while True:
data = ws.fetch(subs[0])
if data:
print(data)

What can be the reason of this error?

Thank you!!!