Bitcoin Forum
July 03, 2024, 10:21:45 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1] 2 3 »  All
  Print  
Author Topic: webserver connecting to a VPS  (Read 2800 times)
cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 02, 2015, 05:59:00 AM
 #1

Hello I neeed some help, I have been working on this for a little over a week and just can not figure it out.

I have a wallet running on a VPS and I have a website on a webserver that needs to communicate with the wallet on the VPS.

No matter what i do the web server always gets an error "Cant connect to wallet. Make sure the info is correct and try again"

My wallet.conf

rpcuser=myusername
rpcpassword=my password
listen=1
daemon=1
server=1
rpcconnect=VPS IP
rpcconnect=Webserver IP
rpcconnect=Webserver secondary IP
rpcallowip=Webserver IP
rpcallowip=Webserver secondary IP
rpcallowip=VPS IP
rpcallowip=127.0.0.1
rpcport=11311
port=11310
addnode=63.246.129.56

Ok I said webserver secondary IP becasue the techs at the place where we bought the webserver and VPS (which is the same company) told me
"The actual connection ip will show up (secondary IP) not (Webserver IP) I think thats the error."
SO

Here is what the webserver is asking for.

Wallet info

Host:  Host
Login: Wallet User
Pass: Wallet Password
Port: port

What i have tried

Wallet info

Host:  VPS IP
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: rpc port from wallet.conf

in addition I have also tried

Host:  VPS IP
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: port from wallet.conf

My question Since I have to log into the VPS do i need to put something else in the VPS to allow my Webserver  to gain access without a username and pasword, like I need when logging into my VPS, the script asks for the wallet info but not the actual login info for the VPS.

I am new to all of this so please have patience with me.

ALso they installed CSF firewall on the VPS is there something I need to do to allow the webserver thru the CSF firewall?
What about in the Apache2.conf is there something I need to input there?

 Thank you for your help.

vm1990
Legendary
*
Offline Offline

Activity: 1540
Merit: 1002



View Profile
February 03, 2015, 02:13:42 AM
 #2

the webserver side only needs the rpc and vps ip stuff not the vps login info. type into google "can you see me" and look for a port testing tool to see if the port your using is open or not. this looks like an issue with the firewall on the vps

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 05:28:51 PM
 #3

the webserver side only needs the rpc and vps ip stuff not the vps login info. type into google "can you see me" and look for a port testing tool to see if the port your using is open or not. this looks like an issue with the firewall on the vps

I will have the techs at the company where they are both purchased look into that, They said all the ports associated with this program are open and ready for communications tho.  I do know when you tlel it to use the rpc port it takes a few seconds for the error to pop up, BUT if you use the port listed in th conf file it takes about 30 to 60 seconds before the error pops up.

I will try the port testing tool now than you sir. I will say when we first bought the VPS it cme under and atrocious attack over 10,000 failed logings in less than 24 hours so they installed CSF Firewall. But they were supposed to have whitelisted my IP and the webserver IPS form that.

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 05:36:57 PM
 #4

the webserver side only needs the rpc and vps ip stuff not the vps login info. type into google "can you see me" and look for a port testing tool to see if the port your using is open or not. this looks like an issue with the firewall on the vps

I did this with the
sudo netstat -plunt

it says netcoind is listening on 11310 and 11311 on tcp6 and 11310 on tcp

cr1776
Legendary
*
Offline Offline

Activity: 4088
Merit: 1304


View Profile
February 04, 2015, 05:44:28 PM
 #5

Can you telnet from your server node to the bitcoind server on the ports that are open?  (Or do a scan from your web server to your bitcoind server to see if those ports are accessible externally?)

When you tried it from here:
http://www.canyouseeme.org

did it show they were open?


cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 06:21:16 PM
 #6

Here is the error log from what I am getting
 
[04-Feb-2015 02:03:02 America/New_York] PHP Fatal error:  Uncaught exception 'Exception' with message 'Incorrect response id (request id: 1, response id: )' in /home/dicefort/public_html/netcoin/install/driver_test.php:68
 
Stack trace:
#0 /home/dicefort/public_html/netcoin/install/driver_test_call.php(12): jsonRPCClient->__call('getbalance', Array)
#1 /home/dicefort/public_html/netcoin/install/driver_test_call.php(12): jsonRPCClient->getbalance()
#2 {main}
  thrown in /home/dicefort/public_html/netcoin/install/driver_test.php on line 68
_______________________________________________________________________________ __________
the whole /driver_test_call.php file (Line 12 is in red I deleted a lot of lines that were spaces to shorten the code Smiley
 
<?php
/*
 *  © BitcoinDice
*/
include 'driver_test.php';
$test=new jsonRPCClient('http://'.$_GET['w_user'].':'.$_GET['w_pass'].'@'.$_GET['w_host'].':'.$_GET['w_port'].'/');
@$test_call=$test->getbalance();
echo json_encode(array('result'=>$test_call));
?>
_______________________________________________________________________________ __________
 
driver_test.php (Line 68 is in red)
 
<?php
/*
 *  © BitcoinDice
*/
class jsonRPCClient {
private $debug;
private $url;
private $id;
private $notification = false;
public function __construct($url,$debug = false) {
$this->url = $url;
empty($proxy) ? $this->proxy = '' : $this->proxy = $proxy;
empty($debug) ? $this->debug = false : $this->debug = true;
$this->id = 1;
}
public function setRPCNotification($notification) {
empty($notification) ?
$this->notification = false
:
$this->notification = true;
}
public function __call($method,$params) {
if (!is_scalar($method)) {
throw new Exception('Method name has no scalar value');
}
if (is_array($params)) {
$params = array_values($params);
} else {
throw new Exception('Params must be given as array');
}
if ($this->notification) {
$currentId = NULL;
} else {
$currentId = $this->id;
}
$request = array(
'method' => $method,
'params' => $params,
'id' => $currentId
);
$request = json_encode($request);
$this->debug && $this->debug.='***** Request *****'."\n".$request."\n".'***** End Of request *****'."\n\n";
$opts = array ('http' => array (
'method'  => 'POST',
'header'  => 'Content-type: application/json',
'content' => $request
));
$context  = stream_context_create($opts);
if ($fp = fopen($this->url, 'r', false, $context)) {
$response = '';
while($row = fgets($fp)) {
$response.= trim($row)."\n";
}
$this->debug && $this->debug.='***** Server response *****'."\n".$response.'***** End of server response *****'."\n";
$response = json_decode($response,true);
} else {
throw new Exception('Unable to connect to '.$this->url);
}
if ($this->debug) {
echo nl2br($debug);
}
if (!$this->notification) {
if ($response['id'] != $currentId) {
throw new Exception('Incorrect response id (request id: '.$currentId.', response id: '.$response['id'].')');
}
if (!is_null($response['error'])) {
throw new Exception('Request error: '.$response['error']);
}
return $response['result'];
} else {
return true;
}
}
}
?>

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 06:24:33 PM
 #7

Can you telnet from your server node to the bitcoind server on the ports that are open?  (Or do a scan from your web server to your bitcoind server to see if those ports are accessible externally?)

When you tried it from here:
http://www.canyouseeme.org

did it show they were open?




yes telnet connects

root@webserver hosting:~# telnet MY.VPS.IP.ADDY 11310
Trying MY.VPS.IP.ADDY...
Connected to MY.VPS.IP.ADDY.
Escape character is '^]'.
^]
telnet> q
Connection closed.



root@webserver hosting:~# telnet MY.VPS.IP.ADDY 11311
Trying MY.VPS.IP.ADDY...
Connected to MY.VPS.IP.ADDY.
Escape character is '^]'.
^]
telnet> q
Connection closed.

http://www.canyouseeme.org

does not let me change the IP address, I can change the port but not the IP address

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 06:37:00 PM
 #8

I have 2 questions

First one,

 I installed the Netcoind in the root directory of the VPS, I have since moved the netcoin folder yet I think all the config and wallet info is still in the root directory would this block communications?

Second one, (if the directory situation is not the problem)

Is the program possibly by default somehow calling bitcoind and not netcoind and possibly by default sending a message

bitcoind getbalance

instead of

netcoind getbalance

lisek229
Sr. Member
****
Offline Offline

Activity: 344
Merit: 250



View Profile
February 04, 2015, 06:53:59 PM
Last edit: February 04, 2015, 07:08:12 PM by lisek229
 #9

Calling wallet under his name.
coind, for example, Bitcoin has bitcoind, Litecoin has litecoind

What you get if you type the command:
or
netcoind getinfo

What do you specified in the $ _GET ['w_host']

You mean the same coin?
https://github.com/netcoinproject/netcoin

Code:
$test=new jsonRPCClient('http://user:pass@your_ip_server:rpc_coin_port');

Netcoin RPC Port:  11311
lisek229
Sr. Member
****
Offline Offline

Activity: 344
Merit: 250



View Profile
February 04, 2015, 07:27:43 PM
 #10

The problem is probably in the fact that the coin daemon does not allow a connection to the outside.

Try these settings in the file  wallet conf:
Code:
rpcuser=username
rpcpassword=password
daemon=1
rpcallowip=*
rpcport=11311
port=11310
addNode=63.246.129.56

After the change, restart the coin wallet
cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 07:41:10 PM
 #11

The problem is probably in the fact that the coin daemon does not allow a connection to the outside.

Try these settings in the file  wallet conf:
Code:
rpcuser=username
rpcpassword=password
daemon=1
rpcallowip=*
rpcport=11311
port=11310
addNode=63.246.129.56

After the change, restart the coin wallet

When trying with teh script from my webserver I put in my VPS ip Address, when trying on the VPS I use local host

Wallet info( when the script is on the webserver and the wallet is on my VPS)

Host:  Host
Login: Wallet User
Pass: Wallet Password
Port: port

What i have tried

Wallet info

Host:  VPS IP
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: rpc port from wallet.conf

in addition I have also tried

Host:  VPS IP
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: port from wallet.conf

-------------------------------------------------------------------------

Wallet info( when the script is on the VPS and the wallet is on my VPS)


Host:  Host
Login: Wallet User
Pass: Wallet Password
Port: port

What i have tried

Wallet info

Host:  localhost
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: rpc port from wallet.conf

in addition I have also tried

Host:  localhost
Login: rpcusername from wallet.conf
Pass: rpcpassword from wallet.conf
Port: port from wallet.conf

My conf file

rpcuser=myusername
rpcpassword=mypassword
listen=1
daemon=1
server=1
rpcconnect=VPS IP
rpcconnect=Webserver IP
rpcconnect=Webserver secondary IP
rpcallowip=Webserver IP
rpcallowip=Webserver secondary IP
rpcallowip=VPS IP
rpcallowip=127.0.0.1
rpcport=11311
port=11310
addnode=63.246.129.56

cr1776
Legendary
*
Offline Offline

Activity: 4088
Merit: 1304


View Profile
February 04, 2015, 07:56:26 PM
 #12

Hey,
Have you checked to make sure this line, the red part:

Code:
$test=new jsonRPCClient([font=Verdana][b]'http://'.$_GET['w_user'].':'.$_GET['w_pass'].'@'.$_GET['w_host'].':'.$_GET['w_port'].'/'[/b][/font]);

is generating the expected URL?

Since you can telnet to that port on the coin server from the web server, the port is open and listening.   You'd want to check that you are really generating the right URL with the right user/pw, host/port combo.

Also, if you do a
netcoind getinfo

(or whatever) while on the coind server, does it return information?


If those are correct then...hmmmm...
lisek229
Sr. Member
****
Offline Offline

Activity: 344
Merit: 250



View Profile
February 04, 2015, 08:04:38 PM
 #13

Try files from this link:

http://white-bitcoin.com/test.zip

In the index.php file, enter the data from the file conf wallet
Upload files to the webserver.

Wallet conf file on the server vps should look like this:

Code:
rpcuser=username
rpcpassword=password
daemon=1
rpcallowip=*
rpcport=11311
port=11310
addNode=63.246.129.56

Restart the coin wallet

Call the address of the page with the file index.php

If the coin wallet is working correctly you should get information from getinfo

If the coin wallet does not work it should throw an error.

Tell me what you receive.
cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 09:44:42 PM
 #14

Hey,
Have you checked to make sure this line, the red part:

Code:
$test=new jsonRPCClient([font=Verdana][b]'http://'.$_GET['w_user'].':'.$_GET['w_pass'].'@'.$_GET['w_host'].':'.$_GET['w_port'].'/'[/b][/font]);

is generating the expected URL?

Since you can telnet to that port on the coin server from the web server, the port is open and listening.   You'd want to check that you are really generating the right URL with the right user/pw, host/port combo.

Also, if you do a
netcoind getinfo

(or whatever) while on the coind server, does it return information?


If those are correct then...hmmmm...

doing a netcoind getinfo does display results and I have sent coins there and they show in the balance, I thought maybe it was because there were no coins in the wallet so i sent some.

how do I check
Code:
$test=new jsonRPCClient([font=Verdana][b]'http://'.$_GET['w_user'].':'.$_GET['w_pass'].'@'.$_GET['w_host'].':'.$_GET['w_port'].'/'[/b][/font]);

to make sure it is generating the expected URL?

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 09:52:31 PM
 #15

Try files from this link:

http://white-bitcoin.com/test.zip

In the index.php file, enter the data from the file conf wallet
Upload files to the webserver.

Wallet conf file on the server vps should look like this:

Code:
rpcuser=username
rpcpassword=password
daemon=1
rpcallowip=*
rpcport=11311
port=11310
addNode=63.246.129.56

Restart the coin wallet

Call the address of the page with the file index.php

If the coin wallet is working correctly you should get information from getinfo

If the coin wallet does not work it should throw an error.

Tell me what you receive.

I will try this but it will be in a day or so,

By trying to  move it from the root directory i deleted it Sad so now it has to syn in again, I also noticed I could not copy the old wallet.dat file I had on backup, no matter how I tried it always reverts back to the new wallet.dat file, But no problems, I kept it on my computer and opened the wallet on my computer and sent those coins to my personal wallet then deleted that wallet.dat file. I just thought it was weird it would not copy or replace the new wallet.dat file. even if I deleted the one that was with the install and uploaded the old wallet.dat file 2 things still happened, the wallet.dat file was green in SSH prompt and it still reverted back to the wallet.dat file that came in the new install.

lisek229
Sr. Member
****
Offline Offline

Activity: 344
Merit: 250



View Profile
February 04, 2015, 10:01:24 PM
 #16

coin wallet (netcoind) may be in the directory as compiled or upload it to the root folder

coin wallet  not need be synchronized to my script will work for you

To replace wallet.dat file, you need to stop the coin wallet (netcoind)
cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 10:27:55 PM
 #17

coin wallet  not need be synchronized to my script will work for you

your test showed the getinfo I see when I type netcoind getinfo

coin wallet (netcoind) may be in the directory as compiled or upload it to the root folder

To replace wallet.dat file, you need to stop the coin wallet (netcoind)

I did stop the wallet before maing any changes, but it still did very weird things LOL I even stopped and rebooted VPS and still same problems But like I said it is very OK no problems Smiley I just moved the coins out of the old wallet and threw it away since I have to resync anyways Smiley

lisek229
Sr. Member
****
Offline Offline

Activity: 344
Merit: 250



View Profile
February 04, 2015, 10:38:10 PM
 #18

coin wallet  not need be synchronized to my script will work for you

your test showed the getinfo I see when I type netcoind getinfo

coin wallet (netcoind) may be in the directory as compiled or upload it to the root folder

To replace wallet.dat file, you need to stop the coin wallet (netcoind)

I did stop the wallet before maing any changes, but it still did very weird things LOL I even stopped and rebooted VPS and still same problems But like I said it is very OK no problems Smiley I just moved the coins out of the old wallet and threw it away since I have to resync anyways Smiley



In that case, it must also work getbalance, getnewaddress, etc.

Your script should work too.
cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 10:44:25 PM
 #19

I love programming, what should work never does what shouldnt work sometimes does, and when its broke, and you fix it, you hardly ever know how or why HAHA your just happy it worked HAHA

cyberpinoy (OP)
Hero Member
*****
Offline Offline

Activity: 1008
Merit: 502



View Profile WWW
February 04, 2015, 10:56:58 PM
 #20

I found this in the index.php


fwrite($w_file,'$driver_login=\'http://'.$_POST['w_user'].':'.$_POST['w_pass'].'@'.$_POST['w_host'].':'.$_POST['w_port'].'/\';'."\n");

however I looked in every folder and file and can not find a driver_login file anywhere is this a problem??

Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!