gopcua / opcua

Native Go OPC-UA library
MIT License
829 stars 253 forks source link

Initial Server Implementation #737

Open danomagnum opened 2 weeks ago

danomagnum commented 2 weeks ago

Re-opening this pull request after working through issues and figuring out which commit I missed while rebasing previously.

Of the 86,027 lines this pull request shows, 72,368 of them are from the nodeset2.xml file that is now included to allow the server to boot-strap itself - I left it as part of the repo instead of using a script to download it at buld time or something because it is embedded. An additional 5,719 are in the Opc.Ua.Di.NodeSet2.xml file used in one of the server examples showing how to use a nodeset to create a server.

oldmaCloud commented 1 week ago

微信截图_20240709230908 i test demo with ua expert ,there are some errors.

danomagnum commented 1 week ago

Ua is such a trash over complicated protocol. Did you just run one of the examples as is?

oldmaCloud commented 1 week ago

yes, go mod init ua_test go get github.com/gopcua/opcua@server and copy examples/server/map_server and run it

oldmaCloud commented 1 week ago

Loading cert/key from cert.pem/key.pem Failed to load certificate: open cert.pem: The system cannot find the file specified. New Node Set: 2022-11-01T00:00:00Z doing objects. New Node Set: 2022-11-01T00:00:00Z Duplicate reference type FromState Duplicate reference type HasSubtype Duplicate reference type HasModellingRule Duplicate reference type HasDescription Duplicate reference type ToState Duplicate reference type HasDictionaryEntry Duplicate reference type HasEffect Duplicate reference type HasCondition Duplicate reference type HasAddIn Duplicate reference type HasTypeDefinition Duplicate reference type HasCause Duplicate reference type HasComponent Duplicate reference type HasProperty Duplicate reference type HasEventSource Duplicate reference type Organizes Duplicate reference type HasFalseSubState Duplicate reference type HasInterface Duplicate reference type HasNotifier Duplicate reference type HasGuard Duplicate reference type HasEncoding Duplicate reference type HasTrueSubState doing BaseDataType doing root. map namespace 1 added at index 1 map namespace 2 added at index 2 Started listening on [opc.tcp://0.0.0.0:4840 opc.tcp://localhost:4840 opc.tcp://lenovo:4840] Press CTRL-C to exit sessionBroker.Session: error looking up session i=1988677739 it is startup logs

danomagnum commented 1 week ago

yes, go mod init ua_test go get github.com/gopcua/opcua@server and copy examples/server/map_server and run it

So I did this same thing and didn't have any issues (after I also go got the couple other dependencies).

Which endpoint did you try to connect to? 0.0.0.0, localhost, or the computer name?

Can you verify the specific commit in your go.mod file? Mine is require github.com/gopcua/opcua v0.5.4-0.20240703154006-81653506ce2a

Mine seems to be running without issue connected to the "localhost" endpoint.

image

image

oldmaCloud commented 4 days ago

github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopcua/opcua v0.5.4-0.20240703154006-81653506ce2a h1:B7Y1cTnvuE/D5d3La6KMAHEVMN6wE7JbtRh7LauxPAg= github.com/gopcua/opcua v0.5.4-0.20240703154006-81653506ce2a/go.mod h1:7eCsq3K5yOaYNHDxzFzNavUvuqyiBgA2pi0OYuR3VtU= github.com/pascaldekloe/goe v0.1.1 h1:Ah6WQ56rZONR3RW3qWa2NCZ6JAVvSpUcoLBaOmYFt9Q= github.com/pascaldekloe/goe v0.1.1/go.mod h1:KSyfaxQOh0HZPjDP1FL/kFtbqYqrALJTaMafFUIccqU= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= Mine is this

oldmaCloud commented 4 days ago

2

oldmaCloud commented 4 days ago

ua_test.zip it is all project file

danomagnum commented 3 days ago

I didn't have any issues running what you sent.

What OS / go version are you running?

oldmaCloud commented 2 days ago

go version go1.22.5 windows/amd64, windows 11