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

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.

Related

fsockopen(): unable to connect to remote server ip Codeigniter

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/

How to connect to a Gmail inbox

I am currently trying to connect to a gmail inbox using Perl and
Net::IMAP::Client
with the following code
use strict;
use warnings;
use Net::IMAP::Client;
my $user = '[address]#gmail.com';
my $pwd = '[password]';
my $imap = Net::IMAP::Client->new(
server => 'imap.gmail.com',
user => $user,
pass => $pwd,
ssl => 1, # (use SSL? default no)
ssl_verify_peer => 0, # (use ca to verify server, default yes)
port => 993 # (but defaults are sane)
) or die "Could not connect to IMAP server: $_";
$imap->login or
die('Login failed: ' . $imap->last_error)
But the $imap variable is undef and I am getting this error:
Use of uninitialized value $_ in concatenation (.) or string at testIMAP.pl line 9.
Could not connect to IMAP server: at testIMAP.pl line 9.
I have successfully connected to the mailbox using Outlook, but as I'm not getting an error message I'm not sure where to look. Does anyone know what I'm doing wrong here?
A big thanks to zdim for help troubleshooting.
Firstly, zdim pointed out that I had the incorrect error variable. $_ should have been $!
This revealed the error message "Network is unreachable", however I was able to pint and telnet to 'imap.gmail.com' successfully.
The solution to this was found here
Perl IO::Socket::SSL: connect: Network is unreachable .
Changing the use statement in the Net::IMAP::Client module to the following worked:
use IO::Socket::SSL 'inet4';
After this, the connection was established, but the login would fail with
Login failed: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)
This is due to Gmail's security features. I received an email that allowed me to confirm that the connection was not malicious, and then subsequent logins were successful.
For others, there may be a few solutions to this last one. You may need to issue an 'app password' If two-step authentication is activated, or you might need to toggle on 'allow less secure apps'

454 Error: authentication failed when using Net::SMTP::SSL to send email

I use Net::SMTP::SSL to sent email in Perl, and got "454 Error: authentication failed"
Here is my code:
use Net::SMTP::SSL;
$smtp = Net::SMTP::SSL->new($smtp2, Port => $smtp_port2, Timeout => 10, Debug => 1);
$smtp->auth($login2, $password2);
$smtp->mail($login2);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: Aspiring error email \n");
$smtp->datasend("Date: $today\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit;
And i got these message:
Net::SMTP::SSL=GLOB(0xf9ab80)<<< 454 Error: authentication failed, system busy
It seem i failed to auth, and i am sure the username and pw is correct.
Thanks so much!!!
454 Error: authentication failed, system busy
These are temporary problems.
The mail server is probably not doing local verification of the password, but is using an external system like a Radius or LDAP server, and the connection to this authentication system failed. Just try again later and hope that the problem got resolved.
If the credentials were wrong the server would have send a 535 status code.
See also the status codes in RFC4954.

500 SSL read timeout error in LWP perl

I have a perl script which will post HTTP request to specified server URL (Say: http://some-ip/here_action_url ). My problem is, Sometimes I am getting the below error.
Error:
500 SSL read timeout.
Sample Code:
my $ua = new LWP::UserAgent;
$ua->timeout(30);
my $res = $ua->post( $url, { 'data' => $my_data } );
if(! $res->is_success ) {
# Error Logging
print $res->status_line."\n";
}
else {
$response_content = $res->content;
}
I read about the error. Most of the documents are saying that it is because of the response delay in server side.
I just want to confirm, whether this error is coming because of server response delay? (or) Can be the problem with my perl script?
If you get a result some of the time, and the error at other times, then it looks like your code is working.
If you alway get the 500 error, it indicates a connection problem. Would need to know more about the service you are trying to connect to, does it require certificates or other authentication (which may be needed for secure socket layer connection)

How do I create a new HTTP::Daemon in perl without root permisson?

Line 271 from HTTP::Proxy is this:
my $daemon = HTTP::Daemon->new(%args) or die "Cannot initialize proxy daemon: $!";
When I try to run this script:
use CGI;
use CGI::Carp(fatalsToBrowser);
use HTTP::Proxy;
my $proxy = HTTP::Proxy->new( port => 8080 ); # Edit: I have tried other ports, too, including 3123, 32789, etc.
$proxy->start;
I get this error message from the browser:
Software error:
Cannot initialize proxy daemon: Operation not permitted at HTTP/Proxy.pm line 271.
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.
I assume this is because I need root permission. Are there any ports I can use that don't require root permission? I don't have the root password to the server.
Edit: Apparently I'm supposed to be able to start it without root with 1025 or greater. How would I set up a stacktrace?
You can use any port (that is not already in use) above 1025. If you are getting that message in your browser (on port 8080?), your daemon is already successfully using that port. I'm not sure what other permission issues it might entail. You could check the documentation or try strace