I am trying to connect to an AMQP version server running AMQP 1.0 (Not RabbitMQ).
I am trying to use the package Apache.NMS.AMQP with the example code below
Uri connecturi = new Uri($"amqp://my-server-host:5672");
IConnectionFactory factory = new NMSConnectionFactory(connecturi);
using (IConnection connection = factory.CreateConnection("UserName", "Password}"))
{
using (ISession session = connection.CreateSession())
{
IDestination destination = session.GetQueue("QueueToListenFor");
using (IMessageConsumer consumer = session.CreateConsumer(destination))
{
connection.Start();
consumer.Listener += new MessageListener(OnMessage);
}
}
}
The issue I am having is that the application hangs on this line
ISession session = connection.CreateSession()
Any ideas or recommendations on why this is happening or for another .NET library (With working examples) highly appreciated!
Thanks
Related
I am currently able to connect to the IBM MQ server based on jndi binding file with the following c# code
InitialContext ic = null;
IConnectionFactory confac = null;
IConnection conn = null;
ISession sess = null;
IMessageConsumer cons = null;
IDestination dest = null;
try
{
System.Collections.Hashtable env = new System.Collections.Hashtable();
// Set the URL or PATH where the bindings file is located
env[XMSC.IC_URL] = "file://c:/mqbindings/.bindings";
// Initialize the context
ic = new InitialContext(env);
// Lookup for the connection factory name
confac = (IConnectionFactory)ic.Lookup("myconfactoryname");
// Create connection using the details from connection factory
conn = (IConnection)confac.CreateConnection();
// Create an auto ack session
sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
// Lookup for the destination
dest = (IDestination)ic.Lookup("myqueue");
// ... rest of the code - create consumer or producer
}
catch (XMSException xmsE)
{
// Handle exception
}
However, when the SSL enabled in the IBM MQ Server, it fails to connect. Tried setting different properties (like setting XMSC.IC_PROVIDER_URL to the keystores directory/.jp12 file), but does not seem working.
Exception I got:
IBM.XMS.XMSException: 'CWSMQ0006E: An exception was received during the call to the method ConnectionFactory.CreateConnection: CompCode: 2, Reason: 2059.
I also cannot find any sample code on the official site on how this is working.
Any idea or sample code on this (not necessary in great details, at least, give me some ideas how what I need to set)?
I am currently able to connect to a IBM MQ using IBMXMSDotnetClient by specifying the connection properties directly in the c# code like below.
XMSFactoryFactory factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory connFactory = factory.CreateConnectionFactory();
connFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, "xxx");
connFactory.SetIntProperty(XMSC.WMQ_PORT, 1414);
connFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "xxx");
connFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
connFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "xxx");
But in Java, it seems that it can be done by JNDI bindings file.
From what I can see, it looks like that JNDI is something like TNS file (which specifies the connection details such host, port, SID, etc.) used by the client to connect to server in Oracle. Is my understanding correct?
If it is the case, is it possible to connect to the IBM MQ by JNDI bindings files using IBMXMSDotnetClient? All examples I can find is to set the connection properties (connFactory.SetXXXProperty) directly.
I have this snippet to create initial context and use it to create connection factory and sessions. Hope it will get you started.
InitialContext ic = null;
IConnectionFactory confac = null;
IConnection conn = null;
ISession sess = null;
IMessageConsumer cons = null;
IDestination dest = null;
try
{
System.Collections.Hashtable env = new System.Collections.Hashtable();
// Set the URL or PATH where the bindings file is located
env[XMSC.IC_URL] = "file://c:/mqbindings/.bindings";
// Initialize the context
ic = new InitialContext(env);
// Lookup for the connection factory name
confac = (IConnectionFactory)ic.Lookup("myconfactoryname");
// Create connection using the details from connection factory
conn = (IConnection)confac.CreateConnection();
// Create an auto ack session
sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
// Lookup for the destination
dest = (IDestination)ic.Lookup("myqueue");
// ... rest of the code - create consumer or producer
}
catch (XMSException xmsE)
{
// Handle exception
}
I need to start a proprietary SSH subsystem on a mainframe.
I've migrate my project to dotnet core but it doesn't support ch.ethz.ssh2. I've change lib to Renci.SSHNET but there is no command to start a subsystem on a remote machine.
on ssh2
Session sess = conn.openSession();
int term_width = 0;
int term_height = 0;
sess.requestPTY("dumb", term_width, term_height, 0, 0, null);
sess.startSubSystem("xxx");
on renci.sshnet i've using SshClient
ConnectionInfo connInfo = new ConnectionInfo(
HostIp,
Port,
HostUser,
new AuthenticationMethod[]{
new PasswordAuthenticationMethod(HostUser,HostPass.TrimEnd()),
});
msshclient = new SshClient(connInfo);
msshclient.Connect();
It does not seem to be possible with the public API of SSH.NET.
But if you are willing to modify SSH.NET code, it should be trivial. Start in Session.CreateChannelSession.
I am using the following code to try and connect to Azure DevOps and to retrieve a list of work item types, however I keep getting this exception:
BrowserFlowException: SP324098: Your browser could not complete the
operation
There doesn't seem to be much information around this exception. Does anyone know what's going on here? I am using Visual Studio 2017, Enterprise Edition updated to latest build on a Windows 10 updated to latest build machine.
VssClientCredentials credentials = new VssClientCredentials();
VssClientHttpRequestSettings settings = new VssClientHttpRequestSettings
{
AllowAutoRedirect = true
};
VssHttpMessageHandler vssHandler = new VssHttpMessageHandler(credentials, settings);
using (VssConnection connection = new VssConnection(this.CollectionUri, credentials, settings))
{
connection.ConnectAsync().SyncResult();
// Create instance of WorkItemTrackingHttpClient using VssConnection
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
var workItemTypes = witClient.GetWorkItemTypesAsync(ProjectName).SyncResult(); ; //exception happens here, I see the login box here too
}
In my C# project I have included ChilkatDotNet2.dll in order to connect to a SFTP server. For the moment, I have tried to implemt a simple connection method like the following:
Chilkat.Ftp2 F = null;
F = (Chilkat.Ftp2)new Chilkat.Ftp2();
F.Hostname = "sftp.domain.com";
F.Username = "username";
F.Password = "password";
F.Port = 22;
F.AuthTls = true;
if (!(F.Connect())) {
MainFrm.set_AlertMessage(F.ConnectFailReason);
}
and it always fails connecting and I always get the error 200 which means
Connected, but failed to receive greeting from FTP server.
according to Chilkat documentation.
What am I missing? I have tried to connect to a simple ftp server test (without SSL/TLS) and it connects correctly so I think I am missing something.
The credentials I was given are correct as I tried to connect to the SFTP server with Filezilla.
Thank you.
UPDATE
Chilkat.SFtp v_SFTP = null;
v_SFTP = (Chilkat.SFtp)new Chilkat.SFtp();
if (v_SFTP.Connect("sftp.domain.com", 22) {
if (v_SFTP.AuthenticatePw("username", "password")) {
IDVariant v_SUCCESS = null;
bool v_SUCCESS = v_SFTP.InitializeSftp();
}
}
else {
MainFrm.set_AlertMessage(v_SFTP.LastErrorText);
}
F = (Chilkat.Ftp2)new Chilkat.Ftp2();
Chilkat.Ftp2 is an FTP client. It supports the FTP protocol. SFTP is a completely different protocol which just happens to have a similar name.
If you want to connect to an SFTP server using Chilkat, look at Chilkat.SFtp.