I installed MongoDB the last version
and i want to connect to MongoDB with an other server with this test code.
- installed MongoDB Driver in PHP Server
- Allowed PHP Server IP in MongoDB iptabels:
PHP Code:
<?php
$m = new MongoClient("mongodb://X.X.X.X:27017");
$dbname = $m->selectDB("Test");
$collection = $dbname->selectCollection("Shows");
$data1 = array(
'user_id' => 'salam',
'age' => 20,
'Status' => 'Allll'
);
$dbname = $collection->insert($data1, array('$data1' => 1));
$results = $collection->find();
echo "<pre>";
foreach($results as $test) {
print_r($test);
}
echo "</pre>";
?>
ERROR:
atal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: X.X.X.X.X.X:27017: Connection timed out' in /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php:9 Stack trace: #0 /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php(9): MongoClient->__construct('mongodb://178.1...') #1 /home/payam48/domains/.../public_html/includes/classes/class.doctor.php(519): Mongodatabase->__construct('1c5b98782e44ccd...', 'b2f202952b685b6...') #2 /home/payam48/domains/.../public_html/includes/classes/class.doctor.php(486): Doctor->online_delete() #3 /home/payam48/domains/.../public_html/application/controllers/managedoctor.php(27): Doctor->delete('4') #4 /home/payam48/domains/.../public_html/application/core/router.class.php(118): managedoctorController->delete() #5 /home/payam48/domains/.../public_html/index.php(9): router-> in /home/payam48/domains/.../public_html/includes/classes/class.mongodatabase.php on line 9
Related
Can anyone plz help
I have written a soap server and a client to test and it works in localhost and also in the server but when both are in save place but when I try to connect the localhost to the server it would not work. gives error
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\xampp\htdocs\PN Encryptor\service\client.php:9 Stack trace: #0 D:\xampp\htdocs\PN Encryptor\service\client.php(9): SoapClient->__soapCall('hello', Array) #1 {main} thrown in D:\xampp\htdocs\PN Encryptor\service\client.php on line 9
my code
///server
class EncSoapServer
{
public function hello($id){
return "Hello WOrld";
}
}
$options = ['uri' => 'http://prageethniranjan.epizy.com/service'];
$server = new SoapServer(null, $options);
$server->setClass('EncSoapServer');
$server->handle();
/// Client
$client = new SoapClient(null, array(
'location' => "http://prageethniranjan.epizy.com/service/encript.php",
'uri' => "http://prageethniranjan.epizy.com/service",
'trace' => 1 ));
//echo $return = $client->__soapCall("encrypt",array("4.1","this is a text message","Niranjan",1979,8,true));
try{
$responce = $client->__soapCall("hello",array('id'=>1));
echo $responce;
}
catch(SoapFault $e)
{
$response = $client->__getLastResponse();
echo $response;
$response = str_replace("",'',$response); ///My Invalid Symbol
$response = str_ireplace(array('SOAP-ENV:','SOAP:'),'',$response);
$response = simplexml_load_string($response);
echo $response;
}
i try running on localhost it works
and put both script on server it also works
but could not connect it with server
I want request-response with wsdl in php
But I getting error
"Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized"
WSDL https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl
My code in index.php
$istek = new SoapClient('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl');
$auth = new stdClass();
$auth->Username = '999999';
$auth->Password = '999999testtest';
$header = new SoapHeader('https://servis.turkiye.gov.tr/services/g2g/kdgm/test/uetdsarizi?wsdl', 'AuthHeader', $auth, false);
$istek->__setSoapHeaders($header);
echo "<pre>";
print_r($istek->__getTypes());
echo "</pre>";
echo "<hr /><br /><br /><br />";
$sonuc = $istek->seyahatIzinKontrol(array(
'wsuser' => array(
'kullaniciAdi' => '999999',
'sifre' => '999999testtest')
,
'tcKimlikNo' => '15058023598')
);
if ($sonuc->seyahatIzinKontrol) {
echo 'OK';
}else {
echo 'ERROR';
};
Here is the error I'm getting:
Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in C:\xampp\htdocs\index.php:72 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://servis....', 'http://uetds.un...', 1, 0) #1 C:\xampp\htdocs\index.php(72): SoapClient->__call('seyahatIzinKont...', Array) #2 {main} thrown in C:\xampp\htdocs\index.php on line 72
What my error?
I am using the Solr library.And I have this code:
<?php
namespace Solarium;
use Solarium;
require 'vendor/autoload.php';
require(__DIR__.'\solarium\init.php');
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Client::VERSION . ' - ';
// create a client instance
$config = array(
'endpoint' => array(
'localhost' => array(
'host' => 'localhost',
'port' => 3306,
'path' => '/solarium/',
)
)
);
$client = new Solarium\Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try {
$result = $client->ping($ping);
echo 'Ping query successful';
echo '<br/><pre>';
var_dump($result->getData());
echo '</pre>';
} catch (Solarium\Exception $e) {
echo 'Ping query failed';
}
htmlFooter();
Well.It sorta works.
It gives me this:
Solarium library version: 3.0.0 - Ping query successful
Fatal error: Uncaught Solarium\Exception\UnexpectedValueException: Solr JSON response could not be decoded in C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\vendor\solarium\solarium\library\Solarium\Core\Query\Result\Result.php:158
Stack trace:
#0 C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\ping4.php(34): Solarium\Core\Query\Result\Result->getData()
#1 {main}
thrown in C:\Bitnami\wampstack-7.0.0RC7-\apache2\htdocs\vendor\solarium\solarium\library\Solarium\Core\Query\Result\Result.php on line 158
So The ping was successful.but I get a fatal error after a successful ping.
What am I supposed to get? And what am i doing wrong?
Please help.
I am trying to connect mongodb using php script, below are the details:
PHP Version 7.2.12
Mongo Version: v3.2.18
Code:
$hostPort = "76.34.28.76:27017/mydb";
$username = "test";
$db = "mydb";
$p = "test%402018";
$manager = new MongoDB\Driver\Manager("mongodb://$username:$p#$hostPort", [
"connectTimeoutMS" => 2000,
"socketTimeoutMS" => 3000,
]);
var_dump($manager);
$filter = array();
$options = [
'ssl'=>false
];
$query = new MongoDB\Driver\Query($filter, $options);
$cursor = $manager->executeQuery('db.tmp_collection', $query);
foreach ($cursor as $document) {
var_dump($document);
}
While executing the above script I am getting below error:
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (serverSelectionTryOnce set): [connection timeout calling ismaster on '76.34.28.76:27017'] in C:\xampp\htdocs\index.php:19 Stack trace: #0 C:\xampp\htdocs\index.php(19): MongoDB\Driver\Manager->executeQuery('db.tmp_collection', Object(MongoDB\Driver\Query)) #1 {main} thrown in C:\xampp\htdocs\index.php on line 19
For connecting Mongodb with PHP application, i installed Mongodb Driver in windows and extension was enabled (checked in phpinfo()). Then i execute the folloeing php code
<?php
// Config
$dbhost = 'localhost';
$dbname = 'test';
// Connect to test database
$m = new Mongo("mongodb://$dbhost");
$db = $m->$dbname;
// select the collection
$collection = $db->shows;
// pull a cursor query
$cursor = $collection->find();
foreach($cursor as $document) {
var_dump($document);
}
?>
and it returns a fatal error. How can solve this?
Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: No connection could be made because the target machine actively refused it. ' in C:\xampp\htdocs\check\index.php:7 Stack trace: #0 C:\xampp\htdocs\check\index.php(7): MongoClient->__construct('mongodb://local...') #1 {main} thrown in C:\xampp\htdocs\check\index.php on line 7
This is connection and test wode. check whether it is working in your system or not :
<?php
$m = new MongoClient("localhost");
$dbname = $m->selectDB("Test");
$collection = $dbname->selectCollection("Shows");
$data1 = array(
'user_id' => 'abc',
'age' => 20,
'Status' => 'A'
);
$dbname = $collection->insert($data1, array('$data1' => 1));
$results = $collection->find();
echo "<pre>";
foreach($results as $test) {
print_r($test);
}
echo "</pre>";
?>
Have you started mongod server , i could replicate your error only when i closed mongod server .