Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Error #4

Open
hirenreshamwala opened this issue May 16, 2022 · 6 comments
Open

Error #4

hirenreshamwala opened this issue May 16, 2022 · 6 comments

Comments

@hirenreshamwala
Copy link

Hi,

I am executing sample code but getting following error

Code:

import sys
import hotbit


try:
	authenticatorCode = sys.argv[1]
except Exception as e:
	raise e

email = "xxx"
password = "xxx"


captchaKey = "xxxxxxxxxxxx"

auth = hotbit.auth.login(email=email, password=password, authenticatorCode=authenticatorCode, antiCaptcha=captchaKey) #If you use 2Captcha write twoCaptcha instead of antiCaptcha



client = hotbit.Hotbit(auth)

print(client.balanceQuery())

Error:

Traceback (most recent call last):
  File "/Volumes/MacintoshHD/python/hotbit-bot/main.py", line 19, in <module>
    client = hotbit.Hotbit(auth)
  File "/usr/local/lib/python3.9/site-packages/hotbit/__init__.py", line 6, in Hotbit
    return Hotbit(auth)
  File "/usr/local/lib/python3.9/site-packages/hotbit/reverseApi.py", line 37, in __init__
    self.sessionWS.post('wss://ws.hotbit.io/', json=payload, encryption="gzip", identifiers={"id": 300})
  File "/usr/local/lib/python3.9/site-packages/requestsWS/session.py", line 128, in post
    resp = _post(ws=self.ws, wsUrl=wsUrl, wsData=self.wsData, headers=headers, encryption=encryption, data=data, json=json, waitForResponse=waitForResponse, identifiers=identifiers, timeout=timeout, debug=debug)
  File "/usr/local/lib/python3.9/site-packages/requestsWS/session.py", line 68, in __init__
    ws = create_connection(wsUrl, header=headers, enable_multithread=True)
  File "/usr/local/lib/python3.9/site-packages/websocket/_core.py", line 596, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.9/site-packages/websocket/_core.py", line 253, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "/usr/local/lib/python3.9/site-packages/websocket/_handshake.py", line 51, in handshake
    headers, key = _get_handshake_headers(resource, hostname, port, options)
  File "/usr/local/lib/python3.9/site-packages/websocket/_handshake.py", line 98, in _get_handshake_headers
    if 'header' not in options or 'Sec-WebSocket-Key' not in options['header']:
TypeError: argument of type 'NoneType' is not iterable
@bazickoff
Copy link

I have the same error

@TitoDra
Copy link
Contributor

TitoDra commented May 25, 2022

I got the same.

Replace :
if 'header' not in options or 'Sec-WebSocket-Key' not in options['header']
By : options.get("header") or 'Sec-...'

@jasongoodwin
Copy link

I'm trying requestsWS = 0.0.17 - looks like a bug in requestsWS.
You'll have to update this project as well and install it eg from local after changing setup.py
Just trying this now to confirm that works.

@jasongoodwin
Copy link

@jasongoodwin
Copy link

There is another error though.

---------------------------------------------------------------------------
SSLError                                  Traceback (most recent call last)
/var/folders/zs/51hgdy9d57z10362cmsc12800000gn/T/ipykernel_55560/2428402997.py in <cell line: 1>()
----> 1 client.serverTime()

~/Development/src/python-hotbit/hotbit/reverseApi.py in serverTime(self)
     54             "id": 10
     55         }
---> 56         resp = self.sessionWS.post('wss://ws.hotbit.io/', json=payload, encryption="gzip", identifiers={"id": 10})
     57         return resp.json()
     58 

~/opt/anaconda3/lib/python3.9/site-packages/requestsWS/session.py in post(self, wsUrl, headers, encryption, data, json, waitForResponse, identifiers, timeout, debug)
    126 
    127     def post(self, wsUrl, headers={}, encryption=None, data=None, json=None, waitForResponse=True, identifiers=None, timeout=None, debug=False):
--> 128         resp = _post(ws=self.ws, wsUrl=wsUrl, wsData=self.wsData, headers=headers, encryption=encryption, data=data, json=json, waitForResponse=waitForResponse, identifiers=identifiers, timeout=timeout, debug=debug)
    129         self.ws = resp.ws
    130         self.wsData = resp.wsData

~/opt/anaconda3/lib/python3.9/site-packages/requestsWS/session.py in __init__(self, ws, wsUrl, wsData, headers, encryption, data, json, waitForResponse, identifiers, timeout, debug)
     69 
     70         dataFormatted = JSON.dumps(data) if type(data) == dict else data if data != None else JSON.dumps(json)
---> 71         ws.send(dataFormatted)
     72         self.status_code = 200
     73 

~/opt/anaconda3/lib/python3.9/site-packages/websocket/_core.py in send(self, payload, opcode)
    276 
    277         frame = ABNF.create_frame(payload, opcode)
--> 278         return self.send_frame(frame)
    279 
    280     def send_frame(self, frame):

~/opt/anaconda3/lib/python3.9/site-packages/websocket/_core.py in send_frame(self, frame)
    304         with self.lock:
    305             while data:
--> 306                 l = self._send(data)
    307                 data = data[l:]
    308 

~/opt/anaconda3/lib/python3.9/site-packages/websocket/_core.py in _send(self, data)
    518 
    519     def _send(self, data):
--> 520         return send(self.sock, data)
    521 
    522     def _recv(self, bufsize):

~/opt/anaconda3/lib/python3.9/site-packages/websocket/_socket.py in send(sock, data)
    168             return sock.send(data)
    169         else:
--> 170             return _send()
    171     except socket.timeout as e:
    172         message = extract_err_message(e)

~/opt/anaconda3/lib/python3.9/site-packages/websocket/_socket.py in _send()
    145     def _send():
    146         try:
--> 147             return sock.send(data)
    148         except SSLWantWriteError:
    149             pass

~/opt/anaconda3/lib/python3.9/ssl.py in send(self, data, flags)
   1171                     "non-zero flags not allowed in calls to send() on %s" %
   1172                     self.__class__)
-> 1173             return self._sslobj.write(data)
   1174         else:
   1175             return super().send(data, flags)

SSLError: [SSL: BAD_LENGTH] bad length (_ssl.c:2483)

@jona799t
Copy link
Owner

Hi,

Sorry about the late response, I am currently on vacation.

Did you figure it out? If not then maybe try these commands in the following order:

pip install hotbit --upgrade 
pip install requestsWS --upgrade
pip install websocket-client --upgrade

If it didn't work try joining our Discord since we have some amazing people there who are happy to help.

Best Regards,
Jonathan

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants