Topic RSS18:50, EEST
October 26, 2016
OfflineGood afternoon.
First of all, sorry but I am a novice in all that relates to OPC servers and connections.
I’m trying to connect to Matrikon OPC Server that I have installed and running in a virtual machine, and the same try to connect from the Java SDK against Matrikon server, but i can not.
The next example code (seemingly simple), returns next error on line “client.connect()”: “Failed to retrieve endpoints The server is not available. Opc.tcp: // localhost: 4841 ServiceResult = Bad_ConnectionRejected (0x80AC0000)” Could not Establish a network connection to remote server. “
Could you help to establish the connection via OPC-UA? On the other hand, is it possible other type of connection to a server using OPC UA, like HTTP SOAP requests, insted “opc.tcp”?
Code:
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Locale;
import org.opcfoundation.ua.builtintypes.DataValue;
import org.opcfoundation.ua.builtintypes.LocalizedText;
import org.opcfoundation.ua.core.ApplicationDescription;
import org.opcfoundation.ua.core.ApplicationType;
import org.opcfoundation.ua.core.Identifiers;
import org.opcfoundation.ua.transport.security.SecurityMode;
import com.prosysopc.ua.ApplicationIdentity;
import com.prosysopc.ua.SecureIdentityException;
import com.prosysopc.ua.client.UaClient;
public class SimpleClient {
public static void main(String[] args) throws Exception {
UaClient client = new UaClient(“opc.tcp://localhost:4841”);
client.setSecurityMode(SecurityMode.NONE);
initialize(client);
client.connect();
DataValue value = client.readValue(Identifiers.Server_ServerStatus_State);
System.out.println(value);
client.disconnect();
}
protected static void initialize(UaClient client)
throws SecureIdentityException, IOException, UnknownHostException {
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(“SimpleClient”, Locale.ENGLISH));
appDescription.setApplicationUri(“urn:localhost:UA:SimpleClient”);
appDescription.setProductUri(“urn:prosysopc.com:UA:SimpleClient”);
appDescription.setApplicationType(ApplicationType.Client);
final ApplicationIdentity identity = new ApplicationIdentity();
identity.setApplicationDescription(appDescription);
client.setApplicationIdentity(identity);
}
}
Thank you very much.
18:54, EEST
December 21, 2011
Offline10:03, EEST
October 26, 2016
Offline1 Guest(s)

Log In
Register