Unable to connect to RabbitMQ on server - c#

I have the below code that connects to RabbitMQ on my local machine but when I change Host name from localhost to my servername it fails and returns the error
var factory = new ConnectionFactory();
factory.UserName = "myuser";
factory.Password = "mypassword";
factory.VirtualHost = "/";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.HostName = "localhost";
As soon as I change HostName as below, it returns error
factory.HostName = "myserver";
Exception: None of the specified endpoints were reachable
The AMQP operation was interrupted: AMQP close-reason, initiated by
Library, code=0, text=\"End of stream\", classId=0, methodId=0,
cause=System.IO.EndOfStreamException: Peer missed 2 heartbeats with
heartbeat timeout set to 60 seconds

Instead of connecting this way, it's much easier to connect using a connection string like you would with sql.
Example C#:
var factory = new ConnectionFactory
{
Uri = ConfigurationManager.ConnectionStrings["RabbitMQ"].ConnectionString,
RequestedHeartbeat = 15,
//every N seconds the server will send a heartbeat. If the connection does not receive a heartbeat within
//N*2 then the connection is considered dead.
//suggested from http://public.hudl.com/bits/archives/2013/11/11/c-rabbitmq-happy-servers/
AutomaticRecoveryEnabled = true
};
return factory.CreateConnection();
web.config or app.config
<connectionStrings>
<add name="RabbitMQ" connectionString="amqp://{username}:{password}#{servername}/{vhost}" />
</connectionStrings>

On server, it looks like Host Name is configured different. My Admin looked at logs and looked at configuration and provided me with the Host Name on server.
var factory = new ConnectionFactory();
factory.UserName = "myuser";
factory.Password = "mypassword";
factory.VirtualHost = "/filestream";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.HostName = "myserver";

Related

I cannot connect to a remote PC with WinXP OS with CimSession. I get Error "Microsoft.Management.Infrastructure.CimException:..."

In my application I have to connect to remote PC's mostly with WinXP OS (Older production machines) from my office server. I am starting a CIMSession in order to read the CPU Load of the remote PC. If I use following code I get Error:
"Microsoft.Management.Infrastructure.CimException: The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig" "
The remote IP is added into the TrustedHosts list on the server where my app is running
public void Read_CPU_Load()
{
string Namespace = #"root\cimv2";
string OSQuery = "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor where Name='_Total'";
string domain = "";
string username = "xxxxxx";
var s = new SecureString();
s.AppendChar('P');
s.AppendChar('a');
s.AppendChar('s');
s.AppendChar('s');
s.AppendChar('w');
s.AppendChar('o');
s.AppendChar('r');
s.AppendChar('d');
// create Credentials
CimCredential Credentials = new CimCredential(PasswordAuthenticationMechanism.Default,
domain,
username,
s);
// create SessionOptions using Credentials
WSManSessionOptions SessionOptions = new WSManSessionOptions();
SessionOptions.AddDestinationCredentials(Credentials);
// create Session using computer, SessionOptions
CimSession mySession = CimSession.Create(TagService.IP_to_Connect, SessionOptions);
IEnumerable<CimInstance> queryInstance = mySession.QueryInstances(Namespace, "WQL", OSQuery);
foreach (CimInstance process in queryInstance)
{
CPU_Load_WMI_int = Convert.ToInt16(process.CimInstanceProperties["PercentProcessorTime"]);
}
}

Does RabbitMQ connection fallback from SSL to unsecured, if SSL is not available?

I have setup the following connection factory
var factory = new ConnectionFactory() {
HostName = this.ApplicationConfigurationManager.QueueHostname,
UserName = ...,
Password = ...,
Ssl = new SslOption
{
Enabled = true,
ServerName = this.ApplicationConfigurationManager.QueueHostname,
AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateChainErrors
}
};
The factory endpoint correctly shows as {amqp://localhost:5671}, as 5671 is for SSL, 5672 is for unsecured.
Note that locally I have not yet enabled SSL for RabbitMQ.
What I notice is that when I create a connection:
using (var connection = factory.CreateConnection())
and inspect the remote endpoint, it shows as {[::1]:5672}.
Why? I would expect it to try to connect to 5671 and fail (correctly, as I have not enabled it yet).
Does RabbitMQ ConnectionFactory fallback to 5672 (unsecure) if it finds out that SSL (5671) is not enabled?

Connecting to oracle database with proxy address

So I'm trying to connect to an Oracle database using the Oracle.ManagedDataAccess-library, where I'm using the following datasource:
(DESCRIPTION =(SOURCE_ROUTE = YES)
(ADDRESS_LIST=
(ADDRESS = (PROTOCOL = TCP)(Host = PROXY-OracleConnectionManager)(Port = 1111))
(ADDRESS = (PROTOCOL = TCP) (Host = MAIN-DATABASE) (Port = 0000)))
(connect_data= (UR = A)(SERVICE_NAME = SERVICENAME)))
I'm also providing a user id and password.
We don't have any control over the database on our end, but as far as I know, they are using a connection manager as the first address, which should route us to the next address in the list if we are authenticated. This works when using this in Oracle SQL Developer but does not work programatically with Oracle.ManagedDataAccess.
This is how I build and use the connection string:
var connString = new OracleConnectionStringBuilder
{
{"User Id", settings.DbUserId},
{"Password", settings.DbUserPassword},
{"Data Source", settings.DbDataSource}
};
OracleConnection conn = new OracleConnection(connectionString.ToString())
conn.Open()
When I run this, I get the following error:
ORA-12537: Network Session: End of file
I suspect that the issue is the ADDRESS_LIST and that the routing doesn't work, but I can't say for sure. Anyone able to provide some insight?

while connecting to SAP Quality System, throw an Connection Exception exception

While connecting with SAP Quality System its Gives an Exception is ConnectionException was caught. details below:
Details: ErrorCode=RFC_OK. ErrorGroup=RFC_ERROR_COMMUNICATION. SapErrorMessage=SAP_CMINIT3 : rc=20 > Connect to SAP gateway failed
Connect_PM GWHOST=IPAddress, GWSERV=sapgw02, SYSNR=02
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner 'IP-Address' not reached
And the connection string in App.Config is :
value="sap://CLIENT=643;SYSTEM ID=QSG;LANG=;#A/**IPAddress**/01"
value="sap://CLIENT=643;SYSTEM ID=QSG;LANG=;#A/**IPAddress**/02"
key="userid" value="UserName"
key="password" value="Password"
Program Code
SAPBinding binding = new SAPBinding();
//SAPBinding binding1 = Skelta.SAPConnector.SAPAdapter.SAPConnection.binding;
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;
binding.EnableBusinessObjects = true;
binding.EnableSafeTyping = true;
EndpointAddress address = new EndpointAddress(SAPConnectionString);
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(binding, address);
// add credentials
factory.Credentials.UserName.UserName = SAPUserName;
factory.Credentials.UserName.Password = SAPPassword;
// Open client
factory.Open(TimeSpan.MaxValue);
//get a channel from the factory
irc = factory.CreateChannel();
//open the channel
try
{
irc.Open(TimeSpan.MaxValue);
}
Please help me

MySQL Connection timing out C#

My Code is below:
MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
conn_string.Server = "mysql.***********.com";
conn_string.UserID = "********";
conn_string.Password = "********";
conn_string.Port = 3306;
conn_string.Database = "*********";
var connectionString = conn_string.ToString();
var connection = new MySqlConnection(connectionString);
connection.Open();
The error that I get is System.TimeoutException
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The code worked before when I was on a different network, but now that I have changed networks it no longer works and I get a timeout error on the connection.Open(); command.
Any ideas on what is wrong? I know that the database/server and even the computer I'm using has not changed but my network has.

Categories

Resources