Open jwes-dev opened 4 years ago
hey sorry I took much time to reply. Do you have any error in BTCPay Server logs? @woutersamaey you already saw that?
No worries. Here is the error message from my logs HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2) | btcpay/Client/Adapter/CurlAdapter.php | 77 | #0 btcpay/Client/Client.php(595): BTCPayServer\Client\Adapter\CurlAdapter->sendRequest(Object(BTCPayServer\Client\Request))
This is the only log on I have on my end. I still get this error. So if you want me to try something else to get more logs, let me know what to do
@NicolasDorier unfortunately no, I am unfamiliar with this issue.
@jwes-dev can you try to update curl? maybe you are using an old version of curl?
Tried that too.
I did find that when I changed my php version from 7.3 to 7.2 it started working until I again sent out couple of invalid requests.
curl update didn't work.
Could this be a security mechanism on BTCPay api against DDOS attacks?
@jwes-dev no, ywe have an anti ddos protection, but you would get a proper HTTP code message... Can you try to create an invoice via CURL? To facilitate, you can create a "legacy API Key" to authenticate via Basic authentication. I guess something is wrong with curl rather than the php library.
curl returns false
Thought this might help curl_getinfo returned this ["size_download"]=> float(267) ["download_content_length"]=> float(-1)
@jwes-dev no error on btcpayserver side logs? can you give me your curl request here so I can try?
How do i get btcpayserver side logs?
Do you want curl with url to my instance?
The curl works perfectly with https://testnet.demo.btcpayserver.org/ It has this issue only with my instance to a livenet and only after I sent out some requests with corrupt data
$Headers = [ 'content-type: application/json', 'x-accept-version: 2.0.0', 'Authorization: Basic T3ZSMHZNbDBDUmI3MVVvbDc3MXZRSUk3MUcxb25oQlc3RXlCN25oWTBNRA==', ];
$Data = [ 'price' => 500, 'currency' => 'USD', 'token' => 'OvR0vMl0CRb71Uol771vQII71G1onhBW7EyB7nhY0MD', ];
$ch = \curl_init(); \curl_setopt($ch, CURLOPT_URL, 'https://testnet.demo.btcpayserver.org/invoices'); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($Headers !== null) { \curl_setopt($ch, CURLOPT_HTTPHEADER, $Headers); }
$postData = json_encode($Data); \curl_setopt($ch, CURLOPT_POST, 1); \curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output = \curl_exec($ch); \curl_close($ch); var_dump($output);
one moment I check.
same request with postman is working, checking with curl.
can you run this via command line:
curl -i -H "Content-Type: application/json" -H "Authorization: Basic T3ZSMHZNbDBDUmI3MVVvbDc3MXZRSUk3MUcxb25oQlc3RXlCN25oWTBNRA==" -X "POST" --data "{}" https://testnet.demo.btcpayserver.org/invoices
It works for me.
curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
let me check
If it still does not work, try adding the --http1.1
and let me know if that's better.
ok it's working when I request from my local but fails on server
However when i ran curl from command line it still gave me the error but i also got the response
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2) {"error":"Warning: No wallet has been linked to your BTCPay Store. See the following link for more information on how to connect your store and wallet. (https://docs.btcpayserver.org/getting-started/connectwallet)\n3/13/20 7:20:50 AM: Creation of invoice starting\n"}
curl -i -H "Content-Type: application/json" -H "Authorization: Basic T3ZSMHZNbDBDUmI3MVVvbDc3MXZRSUk3MUcxb25oQlc3RXlCN25oWTBNRA==" -X "POST" --data '{ "price" : 500, "currency": "USD" }' https://testnet.demo.btcpayserver.org/invoices
HTTP/2 200
server: nginx
date: Fri, 13 Mar 2020 07:27:04 GMT
content-type: application/json; charset=utf-8
content-length: 2056
access-control-allow-origin: *
referrer-policy: same-origin
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-frame-options: DENY
strict-transport-security: max-age=31536000
{"facade":"pos/invoice","data":{"url":"https://testnet.demo.btcpayserver.org/invoice?id=XBxxTtTNVqA69wqCYd1tJ2","posData":null,"status":"new","btcPrice":"0.09669123","btcDue":"0.09669123","cryptoInfo":[{"cryptoCode":"BTC","paymentType":"BTCLike","rate":5171.1,"exRates":{"USD":0.0},"paid":"0.00000000","price":"0.09669123","due":"0.09669123","paymentUrls":{"BIP21":"bitcoin:tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv?amount=0.09669123","BIP72":null,"BIP72b":null,"BIP73":null,"BOLT11":null},"address":"tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv","url":"https://testnet.demo.btcpayserver.org/i/BTC/XBxxTtTNVqA69wqCYd1tJ2","totalDue":"0.09669123","networkFee":"0.00000000","txCount":0,"cryptoPaid":"0.00000000","payments":[]}],"price":500.0,"currency":"USD","exRates":{"USD":0.0},"buyerTotalBtcAmount":null,"itemDesc":null,"itemCode":null,"orderId":null,"guid":"fb34180e-56a0-4a7c-9906-678fb8de8371","id":"XBxxTtTNVqA69wqCYd1tJ2","invoiceTime":1584084424000,"expirationTime":1584085324000,"currentTime":1584084424938,"lowFeeDetected":false,"btcPaid":"0.00000000","rate":5171.1,"exceptionStatus":false,"paymentUrls":{"BIP21":"bitcoin:tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv?amount=0.09669123","BIP72":null,"BIP72b":null,"BIP73":null,"BOLT11":null},"refundAddressRequestPending":false,"buyerPaidBtcMinerFee":null,"bitcoinAddress":"tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv","token":"QFZCHAEL7CSDFvmcoLZKnr","flags":{"refundable":false},"paymentSubtotals":{"BTC":9669123.0},"paymentTotals":{"BTC":9669123.0},"amountPaid":0,"minerFees":{"BTC":{"satoshisPerByte":1.0,"totalFee":0.0}},"exchangeRates":{"BTC":{"USD":0.0}},"supportedTransactionCurrencies":{"BTC":{"enabled":true,"reason":null}},"addresses":{"BTC":"tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv"},"paymentCodes":{"BTC":{"BIP21":"bitcoin:tb1qsauravw79a9ks7e9r6whed8r7q5dhr2fn95pzv?amount=0.09669123","BIP72":null,"BIP72b":null,"BIP73":null,"BOLT11":null}},"buyer":{"name":null,"address1":null,"address2":null,"locality":null,"region":null,"postalCode":null,"country":null,"phone":null,"email":null}}}
I think something funky with the curl on the server. What version is it?
curl 7.64.0 It's a debian server
dammit, when you copy my command above same issue?
just a sec let me check
I tried this command on 3 different server and my local machine, all worked.
HTTP/2 400 server: nginx date: Fri, 13 Mar 2020 07:33:04 GMT content-type: application/json access-control-allow-origin: * referrer-policy: same-origin x-xss-protection: 1; mode=block x-content-type-options: nosniff x-frame-options: DENY strict-transport-security: max-age=31536000
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2) {"error":"Warning: No wallet has been linked to your BTCPay Store. See the following link for more information on how to connect your store and wallet. (https://docs.btcpayserver.org/getting-started/connectwallet)\n3/13/20 7:33:04 AM: Creation of invoice starting\n"}
dammit and it happen only on this server? Can you copy paste the output of curl --version
?
yes just a sec
curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 Release-Date: 2019-02-06 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
@jwes-dev I am sorry but I am at loss trying to know what is going on.
what if you add --http1.1
?
let me check
Got this
curl: (18) transfer closed with outstanding read data remaining {"error":"Warning: No wallet has been linked to your BTCPay Store. See the following link for more information on how to connect your store and wallet. (https://docs.btcpayserver.org/getting-started/connectwallet)\n3/13/20 7:41:54 AM: Creation of invoice starting\n"}
Sorry I don't know, is it possible a proxy is messing up the request? Else try another version, mine is
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
might work. Let me try a different version
You said we can check btcpayserver logs. How do I get those logs?
@jwes-dev you can't I can only get it. I checked, nothing wrong on my side.
Aren't btcpay logs stored on my server hosting the btcpayserver instance?
@jwes-dev testnet.btcpayserver.org is my server, not yours.
Terribly sorry. Think there has been a misunderstanding. Earlier I couldn't share the actual url Here's the actual server I was pinging.
https://btcpay.maine-bitcoin.com
I have no issue with testnet.demo.btcpayserver.org. The issue was with the copy of btcpayserver I have.
Terribly sorry about the mixup
How do i get btcpayserver side logs?
Do you want curl with url to my instance?
The curl works perfectly with https://testnet.demo.btcpayserver.org/ It has this issue only with my instance to a livenet and only after I sent out some requests with corrupt data
Perhaps I should have posted this along with the issue as the opener :(. Again terribly sorry about the mixup. Could you help me?
@jwes-dev can you give me a curl request against your server I can test on my side? What kind of deploymet you have ? Docker/Lunanode?
curl --location --request POST 'https://btcpay.maine-bitcoin.com/invoices' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic RWREV25yREhPWkQ3cGRvblA3SENyMGtab1dpSHJHYmtrWWl2N1l2TEJVRA==' \ --data-raw '{"price":500,"currency":"USD","token":"OvR0vMl0CRb71Uol771vQII71G1onhBW7EyB7nhY0MD"}'
The problem was because I did not link a wallet. BUT it should have still returned a error message. In my case it was closing the connection
I tried on your node:
curl --location --request POST 'https://btcpay.maine-bitcoin.com/invoices' --header 'Content-Type: application/json' --header 'Authorization: Basic RWREV25yREhPWkQ3cGRvblA3SENyMGtab1dpSHJHYmtrWWl2N1l2TEJVRA==' --data-raw '{"price":500,"currency":"USD","token":"OvR0vMl0CRb71Uol771vQII71G1onhBW7EyB7nhY0MD"}'
curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
{"error":"Warning: No wallet has been linked to your BTCPay Store. See the following link for more information on how to connect your store and wallet. (https://docs.btcpayserver.org/getting-started/connectwallet)\n3/26/20 8:47:28 AM: Creation of invoice starting\n3/26/20 8:47:28 AM: BTC_USD: The rating rule is coinaverage(BTC_USD)\n3/26/20 8:47:28 AM: BTC_USD: The evaluated rating rule is ERR_RATE_UNAVAILABLE(coinaverage, BTC_USD)\n3/26/20 8:47:28 AM: BTC_USD: Rate rule error (RateUnavailable)\n3/26/20 8:47:28 AM: BTC_USD: Exception reaching exchange coinaverage (Unauthorized access to the API, premium plan needed)\n"}
Sorry I don't really know why you don't have this error and instead connection get cut. btw, you should update your btcpayserver instance, we don't use coinaverage anymore.
Works with pairing, get token, etc. But create invoice request fails
I get the below error Uncaught BTCPayServer\Client\ConnectionException: HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR
I sent out quick consecutive requests where the error said invalid currency. After like 3-4 such requests I started getting this error