Почему после перезагрузки страницы несколько раз возникает ошибка SIGPIPE! Использую приложение Django с nginx для шлюза Bitcoin core

У меня есть приложение Django, которое пытается сделать страницу биткоин-платежей с использованием локального узла bitcoin core, но я продолжаю получать ([Errno 32] Broken pipe), когда страница обновляется для проверки входящих транзакций. Ошибка похожа на ошибку таймаута, но я пробовал несколько методов решения ошибки таймаута, используя uWsgi и параметры Nginx, но ничего не получилось, и я не получил никакой пользы из логов, только из journalctl получил SIGPIPE: writing to a closed pipe/socket/fd

Режим отладки показывает следующее

Traceback (most recent call last):
  File "./wallet/models.py", line 235, in updatedeposit_btc
    unconf_amount = self.bitcoind.unconf_by_addr(address)
  File "./wallet/bitcoind.py", line 70, in unconf_by_addr
    return self.proxy.getreceivedbyaddress(addr, minconf=0)
  File "/project/env/lib/python3.9/site-packages/bitcoin/rpc.py", line 600, in getreceivedbyaddress
    r = self._call('getreceivedbyaddress', str(addr), minconf)
  File "/project/env/lib/python3.9/site-packages/bitcoin/rpc.py", line 231, in _call
    self.__conn.request('POST', self.__url.path, postdata, headers)
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1049, in _send_output
    self.send(chunk)
  File "/usr/lib/python3.9/http/client.py", line 971, in send
    self.sock.sendall(data)
During handling of the above exception ([Errno 32] Broken pipe), another exception occurred:

и у меня в настройках соединения bitcoind .py

from django.conf import settings
from decimal import Decimal
from .rates import rate
import bitcoin
import bitcoin.rpc
from bitcoin.wallet import CBitcoinAddress, CBitcoinAddressError
from django.core.exceptions import ValidationError

try:
    network = settings.BTC_NETWORK
except:
    network = None

if network:
    bitcoin.SelectParams(network)

class Bitcoind:

    MINCONF = settings.BTC_MIN_CONFIRMATIONS
    VIEW_URL = settings.BTC_VIEW_URL
    URL = settings.BITCOIND_URL

    def __init__(self):
        try:
            url = self.URL
        except:
            url = None
            
        self.proxy = bitcoin.rpc.Proxy(service_url=url)
    @staticmethod
    def usd_to_btc(usd):
        return rate.usd_to_btc(usd)

    @staticmethod
    def btc_to_usd(btc):
        return rate.btc_to_usd(btc)

    @staticmethod
    def sats_to_usd(sats):
        return rate.btc_to_usd(Bitcoind.sats_to_btc(sats))

    @staticmethod
    def usd_to_sats(usd):
        return Bitcoind.btc_to_sats(rate.usd_to_btc(usd))

    @staticmethod
    def sats_to_btc(sats):
        return Decimal(sats) / Decimal(1e8)

    @staticmethod
    def btc_to_sats(btc):
        return Decimal(btc) * Decimal(1e8)

    def create_address(self):
        return self.proxy.getnewaddress(account=self.ACC)

    def unconf_by_addr(self, addr):
        return self.proxy.getreceivedbyaddress(addr, minconf=0)

    def conf_by_addr(self, addr):
        return self.proxy.getreceivedbyaddress(addr, minconf=self.MINCONF)

    @staticmethod
    def validate(addr):
        try:
            return CBitcoinAddress(addr)
        except CBitcoinAddressError:
            raise ValidationError(_('BTC address is invalid'), code='invalid_btc_address')
        return None

def btc_address_validator(address):
    return Bitcoind.validate(address)

и мой models.py

    def updatedeposit(self, dp):
        if dp.coin == Coins.BTC:
            return self.updatedeposit_btc(dp)
        else:
            raise WalletException('No such deposit option')

        if dp.status not in STATUS_TO_UPDATE:
            return dp

        try:
            address = self.bitcoind.validate(dp.recv_address)
        except:
            raise WalletException("Invalid BTC address")
        try:
            unconf_amount = self.bitcoind.unconf_by_addr(address)
            conf_amount = self.bitcoind.conf_by_addr(address)
        except:
            raise WalletException('Bitcoind error')

        if unconf_amount > conf_amount:
            dp.status = Status.UNCONFIRMED
            dp.sats_amount = unconf_amount
            dp.save()
            return dp
        if conf_amount == 0:
            delta = timedelta(minutes=settings.DEPOSIT_EXPIRATION)
            if dp.date < timezone.now() - delta:
                dp.status = Status.EXPIRED
                dp.save()
                return dp
            delta = timedelta(minutes=settings.DEPOSIT_EXPIRATION+40)
            if dp.date < timezone.now() - delta:
                dp.status = Status.CANCELLED
                dp.save()
                return dp
            dp.status = Status.WAITING
            dp.sats_amount = 0
            dp.save()
            return dp

пожалуйста, помогите мне

Вернуться на верх