Open Sogl opened 9 years ago
This script works on the first try: https://github.com/rayed/smpp_php
I am also getting this error. Please help!
My logs (with ip addresses removed)...
[Mon Jan 25 ip address] [error] [client ip address] IPv6 addresses for hostname 1: [Mon Jan 25 ip address] [error] [client ip address] IPv4 addresses for hostname 1: ip address 1 [Mon Jan 25 ip address] [error] [client ip address] IPv6 addresses for hostname 2: [Mon Jan 25 ip address] [error] [client ip address] IPv4 addresses for hostname 2: ip address 1 [Mon Jan 25 ip address] [error] [client ip address] Built connection pool of 2 host(s) with 2 ip(s) in total [Mon Jan 25 ip address] [error] [client ip address] Connecting to ip address 1:port... [Mon Jan 25 ip address] [error] [client ip address] Socket connect to ip address 1:port failed; Operation now in progress [Mon Jan 25 ip address] [error] [client ip address] Connecting to ip address 2:port... [Mon Jan 25 ip address] [error] [client ip address] Socket connect to ip address 2:port failed; Operation already in progress
Hi @MikeG-LSG, Could you please ensure the server and its port are reachable?
On Linux you can run nc -zv <host/ip> <port>
or use telnet telnet <host> <port>.
You should get something like that:
Connection to <host> <port> port [tcp/cslistener] succeeded!
Example:
$ nc -zv google.com 80
Connection to google.com 80 port [tcp/http] succeeded!
Also make sure you do not have low timeout values. If you use other than 0, try to increase it - e.g. to 30s as follows:
$transport->setRecvTimeout(30000);
$transport->setSendTimeout(30000);
I am also getting same error.
Fatal error: Uncaught exception 'SocketTransportException' with message 'Could not connect to any of the specified hosts'
When I telnet the server it is getting connected. But when I checked socket_connect() response, it is throwing error(115) - operation now in progress. Any suggestions on this?
As Sogl mentioned, when I try connecting with this script it is working fine.
I was able to resolve this issue and it was happening because of 'timeout' value. After changing to 10 sec it is working fine now.
@Akshath0392 Cool! Can you do a PR?
@Sogl I have not modified any thing, just used setSendTimeout() API to reset the default value from 100 to 10000.
Refer sockettransport.class.php
$transport = new SocketTransport(array($host),$port); $transport->setSendTimeout(10000); $smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction $smpp->debug = true; $transport->debug = true;
// Open the connection $transport->open();
@Akshath0392
Just tested. Error: Fatal error: Uncaught exception 'RuntimeException' with message 'Could not read PDU body' in C:\OpenServer\domains\sms\vendor\php-smpp\php-smpp\smppclient.class.php on line 711
:confounded:
I have html from and this php code:
$server=$_POST['server'];
$port=$_POST['port'];
$username=$_POST['username'];
$password=$_POST['password'];
$phone=$_POST['phone'];
$header=$_POST['header'];
$message=$_POST['message'];
// Construct transport and client
$transport = new SocketTransport(array($server), $port);
$transport->setRecvTimeout(10000);
$transport::$forceIpv4 = true;
$transport->setSendTimeout(10000);
$smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;
// Open the connection
$transport->open();
$smpp->bindTransmitter($username, $password);
// Prepare message
$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress($header, SMPP::TON_ALPHANUMERIC, SMPP::NPI_UNKNOWN);
$to = new SmppAddress($phone, SMPP::TON_INTERNATIONAL, SMPP::NPI_E164);
// Send
$smpp->sendSMS($from, $to, $encodedMessage);
// Close connection
$smpp->close();
Do you have the same lines? Can you provide the last part of your code?
Another error on Linux: Fatal error: Uncaught exception 'SmppException' with message 'Error in the optional part of the PDU Body.' in /var/www/html/sms/vendor/php-smpp/php-smpp/smppclient.class.php on line 622
@Sogl Here you go!
$transport = new SocketTransport(array($host),$port); $transport->setSendTimeout(10000); $smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction $smpp->debug = true; $transport->debug = true;
// Open the connection $transport->open(); $smpp->bindTransmitter($system_id,$password);
// Prepare message $message = 'Hello world'; $encodedMessage = GsmEncoder::utf8_to_gsm0338($message); $from = new SmppAddress('SMPP Test',SMPP::TON_ALPHANUMERIC); $to = new SmppAddress($phoneNumber,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
// Send $message_id = $smpp->sendSMS($from,$to,$encodedMessage,$tags); $status = $smpp->queryStatus($message_id, $from); // Close connection $smpp->close();
I have solve the problem by setting $transport->setSendTimeout(30000);
This script works on the first try: https://github.com/rayed/smpp_php
This script works in Trans-Received mode. I think it carries MsgId in the body of the data collected from server after sending PDU. can you please tell me how to read the body after unpack?
Hi!
This issue related to https://github.com/onlinecity/php-smpp/issues/48
I tried on some Linux machines to send sms and get an error:
Same error on each different machines... i didn't think it is because of the firewall. Telnet works well.