Python error: TypeError: getsockaddrarg: address AF_INET must be a tuple, not int

When I run my program:

import bitcoinrpc
import csv

# docs at https://github.com/massanchik/bitcoin-python3
# docs at https://docs.python.org/3.3/library/csv.html


user = 'user'
password = 'password'
port = '44555'
host='127.0.0.1'

access = bitcoinrpc.connect_to_remote(user, password, host, port)

print(access.getinfo())

I get the following error:

Traceback (most recent call last):
  File "electrum_to_clam.py", line 14, in <module>
    print(access.getinfo())
  File "/usr/local/lib/python3.4/dist-packages/bitcoinrpc/connection.py", line 133, in getinfo
    return ServerInfo(**self.proxy.getinfo())
  File "/usr/local/lib/python3.4/dist-packages/bitcoinrpc/proxy.py", line 116, in __call__
    resp = self._service_proxy._transport.request(postdata)
  File "/usr/local/lib/python3.4/dist-packages/bitcoinrpc/proxy.py", line 67, in request
    'Content-type': 'application/json'})
  File "/usr/lib/python3.4/http/client.py", line 1065, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.4/http/client.py", line 1103, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.4/http/client.py", line 1061, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.4/http/client.py", line 906, in _send_output
    self.send(msg)
  File "/usr/lib/python3.4/http/client.py", line 841, in send
    self.connect()
  File "/usr/lib/python3.4/http/client.py", line 819, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python3.4/socket.py", line 499, in create_connection
    sock.bind(source_address)
TypeError: getsockaddrarg: AF_INET address must be tuple, not int

What could be the reason and how can I fix it?

+4
source share
3 answers

Nhor just wrote it, the port should be int, as indicated here

https://laanwj.imtqy.com/bitcoin-python/doc/bitcoinrpc.html

bitcoinrpc.connect_to_remote(user, password, host='localhost', port=8332, use_https=False)
+2
source

Your port should be int, not str. Using:

port = 44555
+1
source

the tuple is similar (a, b, c ....). The parameter should be a tuple, then try the following:

access = bitcoinrpc.connect_to_remote((user, password, host, port))

or otherwise

con_data = (user, password, host, port)
access = bitcoinrpc.connect_to_remote(con_data)
0
source

Source: https://habr.com/ru/post/1614436/


All Articles