I am learning how to use use "UnifiedAutomation.UaClient.Controls.SelectEndpointCtrl" and I am using the free downloaded versions.
When I click the "+" button, my "Find Servers" dialog always shows exception "No connection could be made because the target machine actively refused it 127.0.0.1:4840".
It looks to me that port number "4840" is default in the UnifiedAutomation.UaClient.Controls.
I have to change my server port number from "48030" to "4840" to make it work.
My question is how to configure the port number when I use UaClient.Controls in my client application?
UaClient.Controls.SelectEndpointCtrl
Moderator: uasdknet
-
- Jr. Member
- Posts: 2
- Joined: 26 Feb 2013, 17:03
Re: UaClient.Controls.SelectEndpointCtrl
I think there is a bug in the "DiscoverBTN_Click" function on SelectEndpointCtrl.
private void DiscoverBTN_Click(object sender, EventArgs e)
{
try
{
this.ServersLV.Items.Clear();
string text = this.MachineNameCB.Text;
if (this.MachineNameCB.SelectedIndex >= 0)
{
text = (string) this.MachineNameCB.SelectedItem;
}
string uriString = "opc.tcp://" + text + ":4840"; //--->BUG: Hard CODE the port number here
if (!Uri.IsWellFormedUriString(uriString, UriKind.Absolute))
{
throw new ArgumentException("The machine name is not a valid DNS name or IP address.", "machineName");
}
if (this.MachineNameCB.SelectedIndex < 0)
{
this.MachineNameCB.SelectedIndex = this.MachineNameCB.Items.Add(text);
}
RequestSettings settings = new RequestSettings {
OperationTimeout = 0x1388
};
//BUG: Use the hard coded uriString here
this.m_discovery.BeginFindServers(uriString, this.m_locales, null, settings, new AsyncCallback(this.OnDiscoverComplete), null);
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}
}
private void DiscoverBTN_Click(object sender, EventArgs e)
{
try
{
this.ServersLV.Items.Clear();
string text = this.MachineNameCB.Text;
if (this.MachineNameCB.SelectedIndex >= 0)
{
text = (string) this.MachineNameCB.SelectedItem;
}
string uriString = "opc.tcp://" + text + ":4840"; //--->BUG: Hard CODE the port number here
if (!Uri.IsWellFormedUriString(uriString, UriKind.Absolute))
{
throw new ArgumentException("The machine name is not a valid DNS name or IP address.", "machineName");
}
if (this.MachineNameCB.SelectedIndex < 0)
{
this.MachineNameCB.SelectedIndex = this.MachineNameCB.Items.Add(text);
}
RequestSettings settings = new RequestSettings {
OperationTimeout = 0x1388
};
//BUG: Use the hard coded uriString here
this.m_discovery.BeginFindServers(uriString, this.m_locales, null, settings, new AsyncCallback(this.OnDiscoverComplete), null);
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}
}