opcflux panic: runtime error: invalid memory address or nil pointer dereference
bnjroos opened this issue · comments
I've installed opcflux and I get the following:
opcflux.exe -conf influx.yml -rate 1s
refresh rate: 1s
2019/10/18 14:04:22 config file: influx.yml
Writing to opc_da_test at http://localhost:8086
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x718fd4]
goroutine 1 [running]:
github.com/go-ole/go-ole.(*IDispatch).VTable(...)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:18
github.com/go-ole/go-ole.getIDsOfName(0x0, 0xc00008b7f8, 0x1, 0x1, 0x0, 0x0, 0xc00008bbb0, 0xc00010e050, 0x2f)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch_windows.go:20 +0x104
github.com/go-ole/go-ole.(*IDispatch).GetIDsOfName(...)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:22
github.com/go-ole/go-ole.(*IDispatch).GetSingleIDOfName(0x0, 0x8e0c76, 0x7, 0xc000106150, 0x2f, 0x0)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:47 +0x6e
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x0, 0x8e0c76, 0x7, 0xc000080001, 0xc00008b918, 0x2, 0x2, 0xc71d00, 0x11c06b0, 0x0)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:63 +0x4a
github.com/go-ole/go-ole/oleutil.CallMethod(...)
C:/Users/Administrator/go/src/github.com/go-ole/go-ole/oleutil/oleutil.go:51
github.com/konimarti/opc.(*AutomationObject).Connect(0xc0000dc270, 0xc000120660, 0xe, 0xc000120670, 0x9, 0x4ce6c8, 0x0, 0x8e4353)
C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:126 +0x1fa
github.com/konimarti/opc.(*AutomationObject).TryConnect(0xc0000dc270, 0xc000120660, 0xe, 0xc000108560, 0x2, 0x2, 0xc64580, 0x8cf940, 0xc000110b60)
C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:161 +0xae
github.com/konimarti/opc.NewConnection(0xc000120660, 0xe, 0xc000108560, 0x2, 0x2, 0xc000136200, 0x6, 0x8, 0x0, 0x0, ...)
C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:444 +0x8a
main.main()
C:/Users/Administrator/go/src/github.com/konimarti/opc/cmds/opcflux/main.go:105 +0x972
Any idea how to make it work ?
thanks,
@bnjroos What OPC DA Automation Wrapper do you have installed? Do the examples in the example folder work? Please add opc.Debug() to your code.
I've reinstalled gbda_aut.dll once again, no more errors however my server is not detected (cf opc-cli output). I manage to browse it using several tools such as MatrikonOPC Explorer, OpenOPC and another java library.
C:\Users\Administrator\go\bin>opc-cli.exe list localhost -d
OPC 2019/10/21 15:06:28 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2019/10/21 15:06:28 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
Found 0 server(s) on 'localhost':
My opc server is codesys v2.3 server.
This package uses the OPC Automation Interface (it loads the wrapper and executes the wrapper's code as you would in a VB application); it does not directly connect to the server unlike the applications you mentioned (see here for an OPC Automation Wrapper introduction).
If the examples work with the Graybox simulation server and Graybox wrapper than the code works. But, if it doesn't work in your setup, it has most likely something to do with the communication between your wrapper and the OPC server. To avoid this, I usually make sure that the entire application stack is 32bit or 64bit (opc da server, wrapper, and golang app). Hope this helps.
I've already put everything in 32bit, I've just installed Gray Box Simulator and my server now shows up however connection fails. Still trying to figure out why.
And gray box is not listed: screencap
Thank's :)
I have the same problem with opc-cli list localhost
.
I have installed gray_simulator
and I can enum it in OPC Client
:
In my Win10 64 bit system, how can I install OPC.Automation.1
? The example also return the same error because in NewAutomationObject
wrappers := []string{"OPC.Automation.1", "Graybox.OPC.DAWrapper.1"}
var err error
var unknown *ole.IUnknown
for _, wrapper := range wrappers {
unknown, err = oleutil.CreateObject(wrapper)
if err == nil {
logger.Println("Loaded OPC Automation object with wrapper", wrapper)
break
}
logger.Println("Could not load OPC Automation object with wrapper", wrapper)
}
if err != nil {
return &AutomationObject{}
}
return &AutomationObject{}
@konimarti Yes, I have already installed OPC Core Components Redistributable (x64) 101.2 3
.
你好,可以提供一个供我调用的函数吗,我调用你这个函数,就可以列出电脑上面所有的opc服务器
而不是用cmd命令
我再次重新安装了gbda_aut.dll,没有更多错误,但是未检测到我的服务器(参见opc-cli输出)。我设法使用MatrikonOPC Explorer,OpenOPC和另一个Java库等几种工具进行浏览。
C:\Users\Administrator\go\bin>opc-cli.exe list localhost -d OPC 2019/10/21 15:06:28 Could not load OPC Automation object with wrapper OPC.Automation.1 OPC 2019/10/21 15:06:28 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1 Found 0 server(s) on 'localhost':
我的opc服务器是codesys v2.3服务器。
你好 请问你解决了吗,我也不行,
I am done with Troubleshooting solution.
OPC 2020/09/19 18:17:15 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2020/09/19 18:17:15 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
OPC 2020/09/19 18:17:15 Connecting to Matrikon.OPC.Simulation.1 on node localhost
OPC 2020/09/19 18:17:15 Connection failed.
err=========> TryConnect was not successful: Connection failed