Bitcoin Forum
December 05, 2016, 08:32:40 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON error, help please  (Read 1139 times)
Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
April 25, 2011, 04:31:55 PM
 #1

Hi,

I've been trying to debug something for 2 hours now, so frustrating.

exception 'Exception' with message 'Unable to connect to http://myusername:mypassword@127.0.0.1:8332/'

Any reason why it wouldn't be able to connect even though my username and password are correct?

It throws this error when I try to do
Code:
$bitcoin -> sendfrom(PROGRAM_NAME,$pay_out_address,0.01);

Also I've double-checked the logs and the 3 args I'm sending to this function are completely valid.

Thanks

1480926760
Hero Member
*
Offline Offline

Posts: 1480926760

View Profile Personal Message (Offline)

Ignore
1480926760
Reply with quote  #2

1480926760
Report to moderator
1480926760
Hero Member
*
Offline Offline

Posts: 1480926760

View Profile Personal Message (Offline)

Ignore
1480926760
Reply with quote  #2

1480926760
Report to moderator
1480926760
Hero Member
*
Offline Offline

Posts: 1480926760

View Profile Personal Message (Offline)

Ignore
1480926760
Reply with quote  #2

1480926760
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480926760
Hero Member
*
Offline Offline

Posts: 1480926760

View Profile Personal Message (Offline)

Ignore
1480926760
Reply with quote  #2

1480926760
Report to moderator
1480926760
Hero Member
*
Offline Offline

Posts: 1480926760

View Profile Personal Message (Offline)

Ignore
1480926760
Reply with quote  #2

1480926760
Report to moderator
fabianhjr
Sr. Member
****
Offline Offline

Activity: 322


Do The Evolution


View Profile
April 25, 2011, 04:43:53 PM
 #2

Can you please give the full raw error?
Also, a little bit more of your code would help to see how you connected.

Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
April 25, 2011, 04:54:21 PM
 #3

The weird thing is I can easily do $bitcoin->validateaddress('biwoejfiwjefiwojeifow');  with no problem; it connects to the wallet and returns valid info.

Code:
Array
(
    [isvalid] => 1
    [address] => biwoejfiwjefiwojeifow
    [ismine] =>
)

However just a couple of lines after that when I try to do the send it says it can't connect.

Code:
try {
$pay_out_address_details=$bitcoin->validateaddress($new_user['pay_out_address']);
echo '<pre>';
print_r($pay_out_address_details);
echo '</pre>';
}
catch (Exception $e) {
echo $e.'<br>';
die("<p>Server error! Please contact the admin.</p>");
}
It gets past that bit, but immediately after it is this, which it breaks on:

Code:
if ($pay_out_address_details['isvalid']==1) {
//add_to_log('Valid address... sending '.$new_user['pay_out_amount'].' BTC...');
$sendamt=number_format($new_user['pay_out_amount'],2,'.','');
if ($sendamt<=1000) {

try {
$bitcoin->sendfrom(PROGRAM_NAME,$new_user['pay_out_address'],$sendamt);
}
catch (Exception $e) {
echo $e.'<br>';
die("<p>Server error! Please contact the admin.</p>");
}

//add_to_log('...sent successfully.');
}
}

Note the add_to_log statements have been commented out.

Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
April 25, 2011, 05:28:21 PM
 #4

Code:
Array
(
    [isvalid] => 1
    [address] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [ismine] =>
)

exception 'Exception' with message 'Unable to connect to http://xxxxxxxxxxxxx:yyyyyyyyyyyyy@127.0.0.1:8332/' in /web/sites/me/_shared/jsonRPCClient.php:140 Stack trace: #0 [internal function]: jsonRPCClient->__call('sendfrom', Array) #1 /web/sites/me/mydomain.com/public_html/_run_test9.php(109): jsonRPCClient->sendfrom('My Site', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', '0.46') #2 {main}

Server error! Please contact the admin.

NFI.

I might need to order a new monitor soon coz I'm about to punch this one after 3 hours.


BioMike
Legendary
*
Offline Offline

Activity: 1256


View Profile
April 25, 2011, 05:31:20 PM
 #5

My experience with the jsonRPCClient was that it was as buggy as hell. I would look into that (not your code).
Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
April 25, 2011, 05:40:59 PM
 #6

Well, I just tested that... exactly the same server, same daemon, same wallet, different domain name and it was able to send 100% fine.

Code:
define('INC','../inc/');
require_once(INC.'jsonRPCClient.php');
 
$bitcoin = new jsonRPCClient('http://xxxxxxxxxxxx:yyyyyyyyyyyyy@127.0.0.1:8332/');


$bitcoin->sendfrom('My Site','xxxxxxxxxxxxxxxxxxxxxxx',1);

 
echo "<pre>\n";
print_r($bitcoin->getinfo());

$listaccounts=$bitcoin->listaccounts();
print_r($listaccounts);

(Username and password are exactly the same in both scripts).

I'll try putting this stupido script onto this other domain...

Alex Beckenham
Full Member
***
Offline Offline

Activity: 154


View Profile
April 25, 2011, 06:22:06 PM
 #7

Wow, problem solved after only 4 hours.

Code:
$bitcoin->sendfrom('My Site','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',0.04);  //works with literals
$bitcoin->sendfrom(SITE_NAME,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',0.04); //works with constant and 2 literals
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],0.04); //works with constant, var and 1 literal
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],$sendamt); //COMPLETELY FUBAR TOOK 4 HOURS OF MY LIFE AWAY SON OF A BITCH I HATE PROGRAMMING
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],(float)$sendamt); //works with constant and 2 vars if 3rd is type cast

I really do love programming though, honestly.

Tags: PHP, JSON, RPC, Unable to connect, float, string, amount, type cast, error, fubar

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!