I was provide a link of OPC server: http://192.168.2.5:54354 and was asked for read an Item value.
I am new to OPC and I assumed that my server is OPC XML-DA but when I try the sample code, it work.
But when I replace my server URL and Item name, it not work, the server address seem to be missing some part
var client = new EasyDAClient();
DAVtqResult[] vtqResults = client.ReadMultipleItems(
new ServerDescriptor { UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" },
new DAItemDescriptor[]
{
"Dynamic/Analog Types/Double",
"Dynamic/Analog Types/Double[]",
"Dynamic/Analog Types/Int",
"SomeUnknownItem"
});
This one work but did not work with my Server URL: http://192.168.2.5:54354
I am not sure what /XmlDaSampleServer/Service.asmx means but I am able to connect to my sever using https://www.kassl.de/opc/explorer.shtml
Are you sure the server is XML-DA? Very few servers use this protocol in my experience. It is usually OPC DA (OPC Classic) or OPC UA.
Is there any security on the server like username and password?
From my experience, you need to be able to establish a connection with an existing client before writing any code. There could be a network or firewall issue. It appears that the server is on your local network. Can you connect to it with the Kassl client from the same server? OPC DA relies on the COM/DCOM components for communication that tend to have many issues with remote connections and firewalls.
Try the following steps:
Ping the server and make sure it replies.
Install an OPC client like Kassl or Kepware on the same Windows machine as the server and see if it can connect.
If it can, disable firewall, antivirus, etc. and see if you can connect remotely.
Check if there are any port-forwarding that needs to be done. You may want to use Wireshark to see what is happening with the data.
Related
I am going to build application (Asp.net C#) to connect RabbitMQ server which is in another country.
So my question is how to connect that server.
I already installed RabbitMQ Client from NuGet Packages.
Is that needed to run RabbitMQ service in my local machine ?
Need to install RabbitMQ Server in my local machine?
From Client some of the parameters i got like
UserName, Password, HostName, Certificate with private key.
I am curious to know which are the basic steps to connect that server from my localhost application.
Can someone provide blog to refer ?
I already tried with different steps but not able to connect.
string vCertSubjectName = "CN=DevRepo, OU=IT, O=OLX, L=KTM, S=Surrey, C=UK";
ConnectionFactory factory = new ConnectionFactory();
factory.AuthMechanisms = new AuthMechanismFactory[] { new ExternalMechanismFactory() };
factory.HostName = "195.168.0.15";
factory.Port = 5673;
factory.Ssl.Certs = getCertificate(vCertSubjectName);
factory.Ssl.ServerName = System.Net.Dns.GetHostName();
factory.Ssl.Enabled = true;
factory.Ssl.Version = SslProtocols.Tls12;
IConnection connection = factory.CreateConnection();
Error coming like connection.start was never received, likely due to a network timeout."
There are very good simple examples of how to write code to send and receive messages to/from RabbitMQ on their site.
Get those examples; set up a RabbitMQ server on your local network; build the examples and verify they work. Once you know how to send/receive to/from a known instance, you can change the connection properties in your send program to point it to the RabbitMQ instance elsewhere.
I would also suggest you do a ping to the IP address of the foreign RabbitMQ server to get an idea of actual transit times. That should give you some idea if the network timeout is a valid issue.
PS. You will need a valid login and password for the RabbitMQ server before it will accept any messages from you. When you build the example programs above as long as you are on the same physical machine where RabbitMQ is running, you can use the default login and password of guest/guest. By default this will NOT work from another machine due to default security configuration of RabbitMQ.
I trying to connect an OPC server with C# in VS2013.
Here is the most important two lines:
OpcServer Srv = new OpcServer();
int rtc = Srv.Connect(...);
The facts which I know:
I'm runing this code another PC, not on localhost (in OPC server)
I know the IP address of OPC server
I know the URI for the OPC: opcda://Helmholz.OPC.S7.DA/{8C5FBBB7-0A62-4fcb-99CC-BEE0D4B0B6DE}
But, I don't know how can I define this information in the Srv.Connect command.
If you are using OPC NET API, you probably want to use something like:
opcda://1.2.3.4/Helmholz.OPC.S7.DA/{8C5FBBB7-0A62-4fcb-99CC-BEE0D4B0B6DE}
I wrote an article about "OPC URLs": http://www.opclabs.com/resources/developer-blog/1086-a-partial-story-of-opc-urls?showall=&limitstart=
My c# console app runs on an different machine than my SQL Server 2014. I use ado.net to connect to it. How can I detect if the sql server automatically reboots after installing windows updates? On my client application I use SystemEvents_SessionEnding but this does not help me.
I read about connection resiliency, but this seems also not to solve this problem.
Is there a specific ado.net event I can capture? Creating an app on the server sending UDP is not my prefered solution, aswell I dont want to use ping etc.
I'm really looking for something like an event to react on.
e.g. the notification services: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlnotificationinfo(v=vs.110).aspx
Thanks!
If you want to see if the server is down or not you can use Ping Class.
using System.Net.NetworkInformation;
var ping = new Ping();
var reply = ping.Send("SqlServerIP");
if (reply.Status == IPStatus.Success)
{
//server is available
}
else
{
//server is down
}
[edit] so not sure what happened, but we ended up resetting the server and turning off/on TCP/IP and Named Pipes and after a restart and updating the settings everything started working again. weirdest thing. anyways thanks for the help guys.
I'm building a C# WPF application for my job, and I'm getting a weird problem that I've been trying to figure out for the past week. The application connects to the server and imports several tables on start up. So I built it out and was testing it with no issues, but when i pass it to our testers, and everyone is getting the following errors:
Provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server
The users are able to connect to the server through other methods (SSMS/Excel VBA), but just through the application it won't work.
I've checked the following:
Remote connections enabled
TCP/IP connections enabled
Firewall settings are the exact same across all users (me included)
application is compiled as 32 bit (saw this in another thread)
We're using SQL Server 2008 and I've tried several connection strings/methods.
below is the code I'm using to connect:
public void Open_DB_Conn(string Connection_Str)
{
try
{
Sql_Conn = new SqlConnection(Conn_Str);
Sql_Conn.Open();
}
catch (Exception e)
{
MessageBox.Show(string.Format("Error Message:{0} Conn String: {1}",e.Message,Conn_Str));
}
}
Below is my connection string (this is just one of many iterations I've used trying to get it working):
Data Source=IP Address;Initial Catalog=DB_Name;User ID=LOGIN;Password=PWD
Anyone know why I would be the only one able to get it to work and that the users are able to login to the server using other applications without a problem? They use it for logging their excel VBA scripts and there aren't any issues there.
Try this - it may be your answer
"The error is reported by client library. While your server is listeing on remote TCP, client will still try TCP and NP connection in order. So the error client behavior is expected. From what you have described, I believe that even though you enabled the remote TCP connection on the XPSP2 machine, you didn't make the TCP listening port an exception of XPSP2 personal firewall. You should follow steps below to resolve this issue.
check the SQL Server Errorlog to make sure SQL Server is now listening on TCP/IP and confirm which port it is listening on. Usually 1433. In the Errorlog, you will see several lines that discuss what SQL Server is listening on. Below is an example:
2006-01-04 01:41:07.65 server SQL server listening on 10.254.1.150: 1433. <--Shows the IP Address and the port.
2006-01-04 01:41:07.65 server SQL server listening on 127.0.0.1: 1433. <--Shows another IP Address and the port.
2006-01-04 01:41:07.69 server SQL server listening on TCP, Shared Memory, Named Pipes.
2006-01-04 01:41:07.69 server SQL Server is ready for client connections
2, Make sure on Windows XP that the firewall is not blocking that port.
3, go to your client machine and run the client network configuration tool (cliconfg.exe) Make sure TCP/IP is enabled, click properties and make sure the port number is the same one as SQL Server is listening on. Here you can enable NP or disable client NP as well.
Once both the client and the server are using TCP/IP with the same port number and the firewall on server machines is not blocked, you should be able to connect.
Hope this helps."
(Ref: http://social.technet.microsoft.com/Forums/sqlserver/en-US/c488cf76-2515-440f-b3f8-9cfad689c5b6/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server?forum=sqldataaccess)
You have to configured your SQl server so that other IP can connect it for that you have to gone through mentioned link
Configure SQL server
What authentication are you using for the SQL Server? Windows Authentication or SQL Server authentication? My suggestion is to first turn on SQL Server authentication and use the sa\password to connect to the server. If you are successful, then ask the others (users of your application) to try with the same connection string. Let me know what you find out.
Be sure that the port specified in:
Data Source="IPAddress,port";Initial Catalog=DB_Name;User ID=LOGIN;Password=PWD
matches the port on your SQL Server. You can check that by going on SQL Server COnfiguration Manager and viewing TCP/IP properties.
EDIT :
It is also the case the port defined by blocked by an external firewall. And the rest Applications use other ports. Try to find out which port you can use (if indeed the are restrictions to your network)
Make sure your SQL Server instance is properly configured to use TCP using Sql Server Configuration Manager.
It is by default disabled in SQL Express, as show below.
I'd like to know more about your "Sql_Conn" class.
Also, try using this for your connection.
using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
string cmdText = "SELECT name FROM sys.tables"
cmd.CommandText = cmdText;
cmd.ExecuteNonQuery();
}
}
I have two .net solutions.
They both have this code:
var connectionString = "Server = ServerName; Database = DatabaseName; Trusted_Connection=True;"
var connection = new SqlConnection(connectionString);
connection.Open();
connection.Close();
And they both use complitely the same connectionString. And they connect to MSSQL Server;
And in the first solution connection.Open() succeeded and in the second one it failed.
Error message : Named Pipes Provider, error: 40 - Could not open a connection to SQL Server
And every time I create new solution it fails. So this connection only works in one specific solution. And also, my teammates tested this and didn't have such issues.
Can you help with hints why it can be so?
Check that your SQL server has the TCP/IP protocol enabled and if it is using dynamic ports, ensure that the SQL Browser service is running.
Make sure that any firewall software (windows firewall etc.) has an exception added for the particular exe (the sqlservr.exe file gets copied into the instance folder, which will be in C:\Program Files\Microsoft SQL Server\{instance name}\MSSQL\Binn, where instance name might look something like MSSQL11.SQLEXPRESS) or TCP port 1433 or UDP port 1434 (TCP 1433 for the SQL service itself assuming standard settings, UPD 1434 for the SQL Browser Service).
Check that the user account used to access the server (it should also have sufficient permissions and the login should be enabled), in this case it will be whatever windows account you are logged in as or whatever account your IIS application pool is running as because you are using Trusted_Connection=True.
Also check that you have an up-to-date SQL Client on your machine, you can get the latest version for windows here.
Open Sql Server Configuration Manager and make sure that the Named Pipes option is enabled for your Sql server instance.
Sorry for disturbing you. My problem was my inattentiveness. I created soluiton on another network machine.