awcullen / opcua

OPC Unified Architecture (OPC UA) in Go.
MIT License
81 stars 18 forks source link

panic: send on closed channel #27

Closed tina2elva closed 1 year ago

tina2elva commented 1 year ago

call Server.Close but the function "requestWorker" is not ending

Exception has occurred: panic "send on closed channel" Stack: 4 0x0000000000e7d146 in github.com/gammazero/workerpool.(WorkerPool).Submit at github.com/gammazero/workerpool@v1.1.3/workerpool.go:109 5 0x0000000000ee0ef7 in github.com/awcullen/opcua/server.(Server).handleRead at github.com/awcullen/opcua@v1.1.0/server/server_service_set.go:2249 6 0x0000000000eadf8b in github.com/awcullen/opcua/server.(Server).handleRequest at github.com/awcullen/opcua@v1.1.0/server/server.go:444 7 0x0000000000ead294 in github.com/awcullen/opcua/server.(Server).requestWorker

awcullen commented 1 year ago

Thank you for reporting this bug. I'll need to wait on worker routines before closing the worker pool.

awcullen commented 1 year ago

To close the server cleanly, I made sure the secure channels and worker pools close before the ListenAndServe routine returns. See tag v1.2.0.