fsockopen(): unable to connect to remote server ip Codeigniter - codeigniter-3

I would like to ask what is something missing or what is wrong with my fsockopen() in codeigneter. Ive been searching for fives days now and I couldnt figure out what is wrong since others who got the same error with mine we are on a different scenario. While them are for sending emails me is to get the Server Status if online or offline.
I`ve been creating a Online Games Web Templater were it can fetch/display data from Game Remote Server to webhosting. I was able to connect MSSQL to a remote server but the fsockeopne() does not work.
Helper.php Codes
function getServerConnection($ip, $port) {
$sockres = #fsockopen($ip, $port, $errno, $errstr, 0.01);
if (!$sockres) {
return '<b class="text-danger">OFFLINE</b>';
} else {
#fclose($sockres);
return '<b class="text-success">ONLINE</b>';
}
}
View Codes
<p class="m-b-10">
<span class="left">LOGIN: <?php echo getServerConnection($server_settings->server_ip, $server_settings->login_port) ?></span>
<span class="float-right">WORLD: <?php echo getServerConnection($server_settings->server_ip, $server_settings->server_port) ?></span></p>
Var_dum $sockres and error
A PHP Error was encountered Severity: Warning Message: fsockopen():
unable to connect to 192.168.1.1:80 (Connection timed out) - JUST
DUMMY IP. IT HAS A REAL REMOTE IP Filename:
helpers/myhelper_helper.php
bool(false) int(110) string(20) "Connection timed out"
The allow_url_fopen = on and remote server firewall has been configure already
Thank you in advance :) sorry for my English I am not really good on this.

I was able to figureout this error it was because I am using wrong port. and make sure you configure correctly into your windows firewall. And try to use this one to check the port https://ping.eu/port-chk/

Related

Simple SMPP Perl Script

I need your help/advices on my very short script I wrote in Perl in order to send SMS via SMPP protocol.
I got a SMS gateway which is perfectly working (sending SMS via HTML request or via web interface works), let's say this gateway has IP 192.168.1.15.
Its SMPP service is listening to TCP 2775 (I can successfully telnet to 2775, so I guess SMPP service is working on my SMS gateway)
my $smpp = Net::SMPP->new_transmitter(192.168.1.15,
port=>2775,
system_id =>"administrator",
password =>"passwdexample") or die;
$resp_pdu = $smpp->submit_sm(destination_addr => '+400123456789',
short_message => 'test message') or die;
die "Response indicated error: " . $Resp_PDU->explain_status() if $resp_pdu->status;
When I run the script, here the error I got :
Response indicated error: Incorrect BIND Status for given command (ESME_RINVBNDS TS=0x00000004) at C:\temp\smpptest.pl line .
Unfortunately, I haven't find so much help on internet, but according to this link : SMPP Errors Codes It says :
You must bind first before any other request is handled.
However, my bind is done with new_transmitter, and I don't get any errors at this point, so I don't understand how it cannot bind the TCP session (my credentials are corrects, I tried that in a telnet session).
That's the first time I use such a plugin, so maybe I'm missing something, and maybe someone has already met this error !
Many thanks for your help :-)
Try to quote the IP address:
Net::SMPP->new_transmitter("192.168.1.15", ...);

Perl File::Fetch Failed HTTP response: 500 Internal Server Error

I'm using a simple perl script to try and download a file from the following URL:
http://www.londonstockexchange.com/products-and-services/trading-services/setsqx/ccp-securities.xls
use File::Fetch;
my $url = 'http://www.londonstockexchange.com/products-and-services/trading-services/setsqx/ccp-securities.xls';
my $ff = File::Fetch->new(uri => $url);
my $file = $ff->fetch() or die $ff->error;
I am getting:
Fetch failed! HTTP response: 500 Internal Server Error [500 Can't connect to www.londonstockexchange.com:80 (connect: Connection refused)]
Could not open socket to 'www.londonstockexchange.com', 'Connection refused
Any ideas how i can get past this?
Could not open socket to 'www.londonstockexchange.com', 'Connection refused
Any ideas how i can get past this?
Direct connection to this site is blocked somewhere.
If you are inside a company there is probably a firewall and some proxy you are required to use. Ask your system administrator.

Apns php error "Failed to connect to APNS: 110 Connection timed out."

I have done apns code for php and objective c from this Apns code
and setup certificate from this link
Sandbox and production apns for sending notification to ios devices is working perfectly on my server.I moved code and same certificate to client server then sending notification is not working.
I debug all php code and found that it stops at this line of code
private function _connectSSLSocket($development) {
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
$this->sslStreams[$development] = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
if(!$this->sslStreams[$development]){
$this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
unset($this->sslStreams[$development]);
return false;
}
return $this->sslStreams[$development];
}
apns.log file shows the error "Failed to connect to APNS: 110 Connection timed out."
Not getting the mistake. Why this error am i getting and not sending notification to ios devices ? Can anyone guide me for this ?
Finally i took vps instead of shared hosting.
Lucabro's comments helped me to solve. Thanks Lucabro.
A good solution is to use a cloud function like firebase to run the actual apns connection and expose an API for your other backend in the shared hosting.
This is what I used when I run in this problem.
Firebase cloud functions are convenient easy to develop and virtually free.
https://firebase.google.com/docs/functions
I'll post my solution to sometimes next week.

Sending a mail with Sendgrid from a Grails 2.0 application on Heroku

I'm trying to send emails from my Grails 2.0 app via Sendgrid on Heroku but I can't find the right configuration. I keep getting "Connection refused" exceptions:
java.net.ConnectException: Connection refused
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:288)
at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:102)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:39)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:149)
The latest configuration I tried is the following:
grails {
mail {
host = "smtp.sendgrid.net"
port = 587
username = System.env.SENDGRID_USERNAME
password = System.env.SENDGRID_PASSWORD
props = [
"mail.smtp.protocol":"smtps",
"mail.smtp.channel":"plain",
"mail.smtp.auth":"true",
"mail.debug":"true"
]
}
}
It looks like you might have a firewall or ISP blocking port 587. Try this: http://support.sendgrid.com/entries/131119-help-smtp-port-25-is-being-blocked
Elmer Thomas, Developer Evangelist at SendGrid.com
Actually, the problem came from my Grails configuration. For some reason, my mail config was reset at some point and what I had in Config.groovy was not used. So the app tried to send emails via localhost and that didn't work. I found a workaround to this problem but I don't understand yet why it works.

can not connect the apples APN server for pusNotification from by PHP code

To connect my server with the APN server I use the following code.
// coonecting the apn server
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $errorNo, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
But I am failed to connect, I print the $errorNo and $errorString
the output was:
error: Connection timed out
errorNo: 110
But I am also getting the following warnings in errorLog:
Unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in /home/riseupla/public_html/applications/apn/apn.php on line 35
What shoud I do?
NOTE:
I can send push notifications by my mac project (using push me baby project).
But my PHP project failed to connect.
You do not say if you run the php from a different machine than your Mac, but if you are using a hosted service for your php site, then it might be that the ISP has blocked port 2195 (and 2196).
Try to run your php on the same machine as you use when running your Mac project and see if this helps. If that's the case, then you ISP has most likely blocked the ports, and you will have to either find a different ISP or have them open the ports.
Claus
You probably solved it.
But for those interested to find out if the ports are blocked: IF you have SSH access to the server a simple way is to check if you can telnet to the server. This way i found out my provider blocked the ports...
:~ telnet gateway.sandbox.push.apple.com 2195
:~ telnet gateway.sandbox.push.apple.com 2196
You should see something like:
Trying 17.172.232.236...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
may be that your server's IP variety, it must be fixed so work!!