Failed to connect to OPC server

664 views
Skip to first unread message

Ming Tomorrow

unread,
May 16, 2016, 2:00:52 AM5/16/16
to openSCADA
Hi All,

I follow HowToStartWithUtgard but got Failed to connect to server.
I can connect to the remote server using the Client.

Code:
package org.openscada.opc.tutorial;
import java.util.concurrent.Executors;
import org.jinterop.dcom.common.JIException;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.da.AccessBase;
import org.openscada.opc.lib.da.DataCallback;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.openscada.opc.lib.da.Server;
import org.openscada.opc.lib.da.SyncAccess;
public class UtgardTutorial1 {
 public static void main(String[] args) throws Exception {
        // create connection information
        final ConnectionInformation ci = new ConnectionInformation();
        ci.setHost("192.168.200.100");
        ci.setDomain("");
        ci.setUser("OPCUser1");
        ci.setPassword("opc123");
        ci.setProgId("Kepware.KEPServerEX.V5");
        //ci.setProgId("SWToolbox.TOPServer.V5");
       
        // ci.setClsid("680DFBF7-C92D-484D-84BE-06DC3DECCD68"); // if ProgId is not working, try it using the Clsid instead
        final String itemId = "_System._Time_Second";
        // create a new server
        final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
       
        try {
            // connect to server
            server.connect();
            // add sync access, poll every 500 ms
            final AccessBase access = new SyncAccess(server, 500);
            access.addItem(itemId, new DataCallback() {
                @Override
                public void changed(Item item, ItemState state) {
                    System.out.println(state);
                }
            });
            // start reading
            access.bind();
            // wait a little bit
            Thread.sleep(10 * 1000);
            // stop reading
            access.unbind();
        } catch (final JIException e) {
            System.out.println(String.format("%08X: %s", e.getErrorCode(), server.getErrorMessage(e.getErrorCode())));
        }
    }
}
Error message:

13:52:40.527 [main] INFO  org.openscada.opc.lib.da.Server - Failed to connect to server
org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000034
 at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
 at org.jinterop.dcom.core.JIProgId.getIdFromWinReg(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
 at org.jinterop.dcom.core.JIProgId.getCorrespondingCLSID(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
 at org.jinterop.dcom.core.JIComServer.<init>(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
 at org.openscada.opc.lib.da.Server.connect(Server.java:123) ~[org.openscada.opc.lib_1.0.0.201303051455.jar:na]
 at org.openscada.opc.tutorial.UtgardTutorial1.main(UtgardTutorial1.java:32) [bin/:na]
Caused by: jcifs.smb.SmbException: The system cannot find the file specified.
 at jcifs.smb.SmbTransport.checkStatus(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbTransport.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbSession.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbTree.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbFile.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbFile.open0(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbFile.open(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbFileOutputStream.<init>(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.TransactNamedPipeOutputStream.<init>(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at jcifs.smb.SmbNamedPipe.getNamedPipeOutputStream(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
 at rpc.ncacn_np.RpcTransport.attach(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
 at rpc.Stub.attach(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
 at rpc.Stub.call(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
 ... 6 common frames omitted
13:52:40.528 [main] INFO  org.openscada.opc.lib.da.Server - Destroying DCOM session...
13:52:40.534 [main] INFO  org.openscada.opc.lib.da.Server - Destroying DCOM session... forked
C0000034: Unknown error (C0000034)
13:52:40.536 [jI_ShutdownHook] INFO  org.jinterop.dcom.core.JISession - About to destroy 0 sessesion which are linked to this session: 1156189790
13:52:40.536 [OPCSessionDestructor] DEBUG org.openscada.opc.lib.da.Server - Starting destruction of DCOM session
13:52:40.536 [jI_ShutdownHook] INFO  o.j.dcom.core.JIComOxidRuntime - destroySessionOIDs for session: 1156189790
13:52:40.536 [OPCSessionDestructor] INFO  org.jinterop.dcom.core.JISession - About to destroy 0 sessesion which are linked to this session: 1156189790
13:52:40.536 [OPCSessionDestructor] INFO  o.j.dcom.core.JIComOxidRuntime - destroySessionOIDs for session: 1156189790
13:52:40.536 [OPCSessionDestructor] INFO  org.openscada.opc.lib.da.Server - Destructed DCOM session


I don`t know what`s wrong in my codes

Jens Reimann

unread,
May 16, 2016, 5:38:17 AM5/16/16
to openSCADA

I don't think there is something wrong with your code. Unless the ProgID is wrong.

However there is some problem looking up the ClassID from the ProgID. This could be wrong access settings, firewall settings or remote registry settings on the server side.

You could try using the ClassID instead.


--
You received this message because you are subscribed to the Google Groups "openSCADA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openscada+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages