Professional OPC
Development Tools

logos

OPC client not connecting the correct port, possible TCP port problem.

More
29 Nov 2018 16:20 #6878 by support
I cannot be 100% sure about this, but here is a possibility:

It looks like that that H1002496-01 resolves to IPv6 localhost address [::1], but the server only uses an IPv4 socket on 127.0.0.1. It's not truly listening on [::1]:4880.

Netstat should show the listening ports accordingly. For example, for one of processes on my machine, I have both
TCP    127.0.0.1:8307         0.0.0.0:0              LISTENING       7368
and
TCP    [::1]:8307             [::]:0                 LISTENING       7368

Best regards

Please Log in or Create an account to join the conversation.

More
29 Nov 2018 15:52 - 29 Nov 2018 15:56 #6877 by CMAC447
I'm connecting to a local computer. PCNameTextBox.Text is the name of the PC. So usually "opc.tcp://H1002496-01:4880/CM100 OpcUa". It's interchangable with just using localhost.
I'm using QuickOPC 2018.2
Last edit: 29 Nov 2018 15:56 by CMAC447.

Please Log in or Create an account to join the conversation.

More
29 Nov 2018 15:50 - 29 Nov 2018 15:51 #6876 by support
Well, to me it looks like that the error that you get after commenting out the Read is a null reference in your code, so you need to debug it on your side. You are probably assuming that AttributeData is always not-null, but that's not the case: It can be null, and it *is* null when there is an error (which is indicated by non-null .Exception in the event notification arguments).

Going back to the original issue, are you connecting to local or remote computer? What's, during your text, in the PCNameTextBox.Text ?

And, you have not answered my question about which QuickOPC version you are using.

Thank you
Last edit: 29 Nov 2018 15:51 by support.

Please Log in or Create an account to join the conversation.

More
29 Nov 2018 14:11 #6875 by CMAC447
Hello, I've been having the same problem, but I do have some more details and I hope you might be able to provide me a clearer picture of what is going wrong, as I haven't been able to find the root of this problem. In the first attached photo, you can see I'm having the same error, just with port 4880 now. In the second photo you can see that port 4880 is listening, and I've confirmed that the PID of port 4880 is the OPC server.

I tried testing my client code a bit and found something interesting. When subscribing to a node we first test with an EasyUAClient.Read operation and then subscribe, which looks like this:
private int Subscribe(UANodeDescriptor NodeDescriptor, int samplingRate, EasyUADataChangeNotificationEventHandler callBack = null)
        {
            //NOTE: This is the OPC server address on the CM100
            UAEndpointDescriptor endpointDescriptor = "opc.tcp://" + PCNameTextBox.Text + ":4880/CM100 OpcUa";
 
 
            //Test if the endpoint and node are real and point to a value
            //   If it's not real the .Read() will throw a UAException
            //   This will be caught in subscribeAll()
            //DEV NOTE: I don't like this test method but it works for now
            CM100Client.Read(endpointDescriptor, NodeDescriptor);
 
            //It's a real subscribtion so we can subscribe
            return CM100Client.SubscribeDataChange(endpointDescriptor, NodeDescriptor, samplingRate, callBack);
        }

If I comment out the read operation, I will get a different error at runtime:
System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=DataViewUI
  StackTrace:
       at DataViewUI.Views.DemoLiveDataUserControl.OnAPPNChanged(UAAttributeData attributedata) in D:\CombinedUI\DataViewUI\Views\Live Data\DemoLiveDataUserControl.xaml.cs:line 453
       at DataViewUI.Views.DemoLiveDataUserControl.<SubscribeALL>b__57_0(Object sender, EasyUADataChangeNotificationEventArgs Eventargs) in D:\CombinedUI\DataViewUI\Views\Live Data\DemoLiveDataUserControl.xaml.cs:line 349
       at OpcLabs.BaseLib.Widgets.NotifyingWidget.<>c__DisplayClass44_0`1.<Callback>b__0()
       at OpcLabs.BaseLib.Widgets.NotifyingWidget.SafeCallback(String name, Action action)
  InnerException: 
Is there any additional information you can give us about what our specific problem is or how exactly our server would be misconfigured?
Thank you for your continued help.
Attachments:

Please Log in or Create an account to join the conversation.

More
23 Sep 2018 13:38 - 29 Nov 2018 15:44 #6705 by support
When making a connection to OPC UA server, QuickOPC first obtains a list of endpoint descriptions from the server, and then selects the endpoint that matches the endpoint selection policy.

If the server is misconfigures, it may return an endpoint that does not work. It seems that in your case, the server returns an endpoint which contains port 4840 - but that port doesn't really work in the end.

The primary way of resolving this would be to look at the server and fix the misconfiguration.

We have a settings (EnforceSameSite, EnforceSamePort in the UAEndpointSelectionPolicy) that would cause QuickOPC to ignore parts of the endpoint URL returned from the server (which is probably what UAExpert does by default). Recent QuickOPC version also have these settings turned on by default. Which version of QuickOPC are you using?

Also note that if the server is not on the same computer as the client, the actual reason might be in the host name returned by the server, and not the port. In the error message, the host part is [::1] - but if the server is remote, it should return the IP address or name by which the clients can actually find it.

Regards
Last edit: 29 Nov 2018 15:44 by support.
The following user(s) said Thank You: CMAC447

Please Log in or Create an account to join the conversation.

More
21 Sep 2018 18:49 #6703 by CMAC447
Hello,
I am having some trouble with my OPC client code. This OPC client recursively finds all the data nodes on a server and outputs them to a .txt file, for some background.
Recently my client stopped connecting to the OPC server and I believe it may be a problem with the TCP port setup. The connection string is: "opc.tcp://[Computer Name]:4880/CM100 OpcUa" which usually works, and I have confirmed this same string works when using UA expert. When I try to connect I get the error shown in the attached image.
I believe that my client is trying to communicate on 4840, while the server is listening on 4880. Am I correct?
If so what can I use the configure the TCP port that the client communicates on?
If not, what would I be doing wrong?

I've also tested the rest of my code using the public OPC server: "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.183 seconds

      

 Recommend this on Google