I'm using this repo to connect to SAP software:
https://github.com/gkralik/php7-sapnwrfc
but I don't know why my script connect and return data successfully from my zfunctions on SAP server only under Command Line Interface CLI
php /path/tomy/script.php
but errors under web browser always return:
Fatal error: Uncaught SAPNWRFC\ConnectionException: Failed to set trace directory in /var/www/html/sap/test.php
or
Exception: Could not open connection
Exception INFO:
Array
(
[code] => 1
[key] => RFC_COMMUNICATION_FAILURE
[message] =>
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner 123.4.5.6:3300 not reached
TIME Sat Feb 4 23:42:27 2023
RELEASE 753
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE /bas/753_REL/src/base/ni/nixxi.cpp
LINE 3067
DETAIL NiPConnect: 123.4.5.6:3300
SYSTEM CALL connect
ERRNO 13
ERRNO TEXT Permission denied
COUNTER 6
)
with any user, and I have checked file permissions too.
Thank you very much for your help
By default, SELinux forbids Apache to make outgoing network connections. If Apache needs to make requests to an outside network service, then run the following command to allow this action.
setsebool -P httpd_can_network_connect on
I am trying to create a remote mongodb server to work with on my CodeIgniter project.
I have updated my mongodb conf file to
// /etc/mongodb.conf
bind_ip = 0.0.0.0
port = 27017
When I access my IP in shell script it working fine.
~$ mongo --host 192.168.20.106
Result Shown:
MongoDB shell version: 2.4.9
connecting to: 192.168.20.106:27017/test
Server has startup warnings:
Mon Nov 2 12:29:34.643 [initandlisten]
Mon Nov 2 12:29:34.643 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Mon Nov 2 12:29:34.643 [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal).
Mon Nov 2 12:29:34.643 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
Mon Nov 2 12:29:34.643 [initandlisten]
IN My another PC 192.168.20.107 has CodeIgniter project called ciproject config/cimongo.php I added below lines to connect with the remote host server.
// Generally localhost
$config['host'] = "192.168.20.106";
// Generally 27017
$config['port'] = 27017;
// The database you want to work on
$config['db'] = "tank_auth";
// Required if Mongo is running in auth mode
$config['user'] = "";
$config['pass'] = "";
/*Defaults to FALSE. If FALSE, the program continues executing without waiting for a database response. If TRUE, the program will wait for the database response and throw a MongoCursorException if the update did not succeed.*/
$config['query_safety'] = TRUE;
//If running in auth mode and the user does not have global read/write then set this to true
$config['db_flag'] = TRUE;
//consider these config only if you want to store the session into mongoDB
//They will be used in MY_Session.php
$config['sess_use_mongo'] = TRUE;
$config['sess_collection_name'] = 'ci_sessions';
Now I want to access this application by using the 192.168.20.107/ciproject
When I access this URL in web its show me error
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 1232
I Already Try this but not getting any solution.
after done with research and with the help of stackoverflow I found solution.
in congif/database.php just make it as FALSE
$db['default']['db_debug'] = FALSE;
Thanks stackoverflow Ref Link:)
2013-11-21 17:26:21 Running command: "['C:\\Python27\\pythonw.exe', '-u', 'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=denashitug', '--passin', 'update', 'C:\\wamp\\www\\sems']"
05:26 PM Application: gcdc2013-sems; version: 1
05:26 PM Host: appengine.google.com
05:26 PM
Starting update of app: gcdc2013-sems, version: 1
05:26 PM Getting current resource limits.
Password for denashitug: 05:26 PM Scanning files on local disk.
2013-11-21 17:26:30,438 ERROR appcfg.py:1656 Invalid character in filename: images/userprofile/cartoon (1).jpg
2013-11-21 17:26:30,438 ERROR appcfg.py:1656 Invalid character in filename: images/userprofile/cartoon (2).jpg
2013-11-21 17:26:30,479 ERROR appcfg.py:1656 Invalid character in filename: images/gallery/cartoon (1).jpg
2013-11-21 17:26:30,480 ERROR appcfg.py:1656 Invalid character in filename: images/gallery/computer (1).jpg
Error 409: --- begin server output ---
Another transaction by user denashitug is already in progress for app: s~gcdc2013-sems, version: 1. That user can undo the transaction with "appcfg rollback".
--- end server output ---
2013-11-21 17:26:32 (Process exited with code 1)
You can close this window now.
I tried using a solution that was recently posted, but I still have same problem what should I do? It says that the application does not contain an app.yaml file, so now what should I do?
The problem is that you have previously aborted an update of your AppEngine app.
Before you can update it again, you first need to rollback that partial update. To do this run the command as it says.
appcgy.py rollback .
Using the code from the PHP manual found here and here
<?php
$mysqli = mysqli_init();
if (!$mysqli) {
die('mysqli_init failed');
}
$mysqli->ssl_set('/path/to/client-key.pem',
'/path/to/client-cert.pem',
'/path/to/ca-cert.pem',
NULL,NULL); //<-- Doesn't matter if the paths are right or wrong
if (!$mysqli->options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0')) {
die('Setting MYSQLI_INIT_COMMAND failed');
}
if (!$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed');
}
if (!$mysqli->real_connect('xx.xx.xx.xx', 'my_user', 'my_password', 'my_db')) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . $mysqli->host_info . "\n";
$mysqli->close();
?>
I'm unable to connect to MySql. It gives the following error:
Message: SQLSTATE[28000] [1045] Access denied for user 'my_user'#'xx.xx.xx.xx' (using password: YES) <-- the client IP
I have narrowed down the problem to the line $mysqli->ssl_set(...).
When I pass wrong paths to the certificates it should throw a SSL certificate error according to this post where the user suffered from the same problem instead it throws the same previous Access denied error.
I managed to make a connection using Navicat to the server with the help of the database admin by configuring the ssl connection as follows:
Notes:
My PHP version is 5.3.15
MySql version used on the remote database server is 5.5.13-55
Both Navicat and the PHP code are run from the same PC.
The database admin created a ssl_user specially for testing. This user is denied normal access and must connect using ssl.
No proxies are used.
I tried PDO and it suffers from the same problem.
I tried mysql->connect(), but it throws a bad handshake error and according to some comments in the manual it doesn't work.
Open ssl is enabled from phpinfo()
So the question is why PHP isn't complaining about the wrong paths to the certificates? It seems PHP is ignoring the line where I set the certificate paths!!
UPDATE:
I tried changing the line where I make the connection to explicitly set the port and use MYSQLI_CLIENT_SSL:
$mysqli->real_connect('xx.xx.xx.xx', 'my_user', 'my_password', 'my_db','3306',NULL,MYSQLI_CLIENT_SSL)
However, I got this error:
Warning: mysqli::real_connect(): (08S01/1043): Bad handshake in ...
UPDATE 2:
This is the result of tcpdump-ing from the database server:
0x0040: 3142 6164 2068 616e 6473 6861 6b65 1Bad.handshake
13:16:18.133282 IP (tos 0x8, ttl 64, id 40823, offset 0, flags [DF], proto: TCP (6), length: 52) xx.xx.xx.202.mysql > xx.xx.xx.130.42766: F, cksum 0xf15f (correct), 112:112(0) ack 79 win 46 <nop,nop,timestamp 19516376 3465907>
0x0000: 4508 0034 9f77 4000 4006 c8a7 c0a8 28ca E..4.w#.#.....(.
0x0010: c0a8 2882 0cea a70e b36c 7e8b 7b4d a169 ..(......l~.{M.i
0x0020: 8011 002e f15f 0000 0101 080a 0129 cbd8 ....._.......)..
0x0030: 0034 e2b3 .4..
13:16:18.133433 IP (tos 0x8, ttl 64, id 17337, offset 0, flags [DF], proto: TCP (6), length: 52) xx.xx.xx.130.42766 > xx.xx.xx.202.mysql: F, cksum 0xb695 (correct), 79:79(0) ack 113 win 92 <nop,nop,timestamp 3480910 19516376>
0x0000: 4508 0034 43b9 4000 4006 2466 c0a8 2882 E..4C.#.#.$f..(.
0x0010: c0a8 28ca a70e 0cea 7b4d a169 b36c 7e8c ..(.....{M.i.l~.
0x0020: 8011 005c b695 0000 0101 080a 0035 1d4e ...\.........5.N
0x0030: 0129 cbd8 .)..
13:16:18.133452 IP (tos 0x8, ttl 64, id 40824, offset 0, flags [DF], proto: TCP (6), length: 52) xx.xx.xx.202.mysql > xx.xx.xx.130.42766: ., cksum 0xb6c3 (correct), 113:113(0) ack 80 win 46 <nop,nop,timestamp 19516376 3480910>
0x0000: 4508 0034 9f78 4000 4006 c8a6 c0a8 28ca E..4.x#.#.....(.
0x0010: c0a8 2882 0cea a70e b36c 7e8c 7b4d a16a ..(......l~.{M.j
0x0020: 8010 002e b6c3 0000 0101 080a 0129 cbd8 .............)..
0x0030: 0035 1d4e .5.N
xx.xx.xx.202 is the database server ip.
xx.xx.xx.130 is my PC ip.
UPDATE 3:
I checked for the password length using the following code:
mysql> select length(Password) from mysql.user where User='youruser'
And the password length was 41.
UPDATE 4:
There might be a hint in the error message returned when I connect using the command line via ssh on the remote server (I uploaded the whole project to the remote server):
mysql -u test_ssl -password --ssl-key=/usr/local/apache2/htdocs/certs/client-key.pem --ssl-cert=/usr/local/apache2/htdocs/certs/WRONG-CERTIFICATE.pem
I get the following error:
SSL error: Unable to get certificate from '/usr/local/apache2/htdocs/certs/WRONG-CERTIFICATE.pem'
ERROR 2026 (HY000): SSL connection error ---> notice the error here
If I don't supply any certificates at all I get the following message:
-bash-3.2$ mysql -u test_ssl -password
ERROR 1045 (28000): Access denied for user 'test_ssl'#'localhost' (using password: YES)
Which is the same error I get when I connect using PHP using correct or invalid paths to the certificates!!
Maybe this means something?
At a first glance, you did not set MYSQLI_CLIENT_SSL option to connection.
if (!$mysqli->real_connect('localhost', 'my_user', 'my_password', 'my_db', null, MYSQLI_CLIENT_SSL)) { ... }
Update:
You could try adding $mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
before $mysqli->ssl_set().
Also, this works for me:
<?php
$pdo = new PDO('mysql:host=ip;dbname=dbname', 'username', 'password', array(
PDO::MYSQL_ATTR_SSL_KEY =>'/etc/mysql/ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT=>'/etc/mysql/ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA =>'/etc/mysql/ssl/ca-cert.pem'
)
);
$stmt = $pdo->query("SHOW TABLES;");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($row);
?>
Update 2:
You may receive a bad handshake if you use old style mysql password (16 bytes long). To check, run the following query:
mysql> select length(Password) from mysql.user where User='youruser'
If you receive 16:
// disable old_passwords:
mysql> SET ##session.old_passwords = 0;
// update password for user used in PHP script:
mysql> SET PASSWORD FOR 'existinguser'#'localhost' = PASSWORD('existingpass');
// check if we have a 41 bytes long password:
mysql> select length(Password) from mysql.user where User='youruser'
And check the connection from PHP script again.
Well we were able to solve the problem, but I'm not sure that this is a practical solution.
First of all we were able to locate the source of the problem which was the MySql client libraries, the ones PHP uses to connect using SSL. PHP had to be complied with those libraries to be able to connect using SSL.
Moreover there was a conflict between the MySql client libraries and OpenSSL libraries.
The only solution to our problem was to re-install everything from scratch. We used a new server, fresh Mysql (latest build) install with all libraries, latest PHP build and latest CentOS distribution.
I have such network configuration (see link - http://s58.radikal.ru/i160/1110/4c/1c2c5d74edd0.jpg)
Where:
Notebook - contain Apache+php+mongodb+php drivers for mongodb+web project on Zend (Windows)
router - virtual station (nat on 192.168.5.23 interface + ipfw)
natd.conf:
interface le0
same_ports
use_sockets
redirect_port tcp 192.168.5.23:27017 27017
redirect_port tcp 192.168.5.23:27017 27017
ipfw:
allow from any to any
virtual station 2 - contain ONLY mongodb (no php, apache, or mongodb php drivers )
1 - ping from notebook to mongodb host and backward - works.
2 - shell on virtual mongodb host: mongo 192.168.5.20:27017 - connected to notebook's mongodb successfully
3 - attempt to connect from notebook to virtual host cause such error:
C:\mongodb1.8.2\bin>mongo 192.168.9.21:27017
MongoDB shell version: 1.8.2
connecting to: 192.168.9.21:27017/test
Sun Oct 02 22:31:14 Error: couldn't connect to server 192.168.9.21:27017 shell/mongo.js:81
exception: connect failed
4 - attempt to use remote host with DB in php project (www.vm.lcl):
an exception occured while bootstrapping
connecting to vm-db1.lcl failed: Unknown error
Stack Trace:
#0 C:\www\vm-db1.lcl\library\Zirrk\Database\MongoConnection.php(16): Mongo->__construct('vm-db1.lcl')
Please, give me advise - in what direction should I search my mistakes!
Thank a lot!
I've solve this problem by changing rule in natd.conf
redirect_port tcp 192.168.5.23:27017 27017
to
redirect_port tcp 192.168.5.23:27017 192.168.9.21:27017
Before understanding how to fix it, I've create in virtual network (192.168.9.0/24) web-server (192.168.9.11) with apache+php+mongo-php-driver (mongodb - was not installed), and tried to connect to 192.168.9.21
$m = new Mongo("mongodb://192.168.9.21:27017");
This was no sense. I've spent whole day in brainstorm and googling information, but still nothing. (Error was in timeout while connection to server). Then I rest for few hours, and understand, that in my case, all traffic goes through Freebsd-gateway host and add to natd.conf
redirect_port tcp 192.168.9.11:27017 192.168.9.21:27017
reboot gate-way server, and it come to work!