Error: The requested service provider could not be loaded or initialized. - socket (2)

I am running a ruby โ€‹โ€‹script that uses Ruby / MySQL and net / ftp. The script runs on a Windows Vista box and tries to create a database and ftp connection to the same remote Solaris server.

Here is the gist of the code:

require 'mysql'
require 'net/ftp'

dbh = Mysql.real_connect(db["host"], db["user"], db["pass"], db["name"])
ftp = Net::FTP.new(ftp["host"])

      

Now if I run the script from the Vista window it is in, everything works as it should. However, the script is called from another server via NRPE and that's when an error occurs.

If I set db ["host"] / ftp ["host"] equal to the FQDN of the remote server, the error I received appears here:

getaddrinfo: no address associated with hostname.

      

After getting this error, I tried to ping the server from within the script and of course it failed when I tried to ping the hostname, however it worked when I ping the IP address.

But if I set db ["host"] / ftp ["host"] to the IP address of the remote server, I get this error:

The requested service provider could not be loaded or initialized. - socket(2)

      

I am having a hard time finding information on how to debug this, so if anyone has any ideas they would be very grateful.

Thanks in advance.

+2


source to share


1 answer


It turns out the script was running remotely from a different user than when it was running locally. I'm not really sure what changed in the environment that caused this issue, but once we configured the remote instance to run as the same user as the local, everything works fine.



0


source







All Articles