![sp_Feed](https://forum.prosysopc.com/wp-content/sp-resources/forum-themes/default/images/sp_Feed.png)
![sp_TopicIcon](https://forum.prosysopc.com/wp-content/sp-resources/forum-themes/default/images/sp_TopicIcon.png)
9:49, EEST
![Avatar](https://forum.prosysopc.com/wp-content/sp-resources/forum-avatars/defaults/userdefault.png)
January 27, 2012
![sp_UserOfflineSmall](https://forum.prosysopc.com/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
Hi,
My Server is running as a Windows Service and I am wondering how to set ServerState to e.g. “SHUTDOWN” when the service is stopped?
Actually, the state according to client is changed to: ServerState changed from Running to CommunicationFault
Is there a listener for shutdown on server?
Thanks
BR
12:22, EEST
![Avatar](https://forum.prosysopc.com/wp-content/sp-resources/forum-avatars/1496998201jaro_researchgate_2017.jpg)
December 21, 2011
![sp_UserOfflineSmall](https://forum.prosysopc.com/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
UaClient is polling the ServerState (1000 ms by default), so it should notice the change, if you call UaServer.shutdown() with a 5 second delay, for example, when the service is requested to close. How do you run it as service – that’s the next question of course.
If the client fails to read Shutdown state, it will notice the change when the read fails – and it results to CommunicationFault.
6:40, EEST
![Avatar](https://forum.prosysopc.com/wp-content/sp-resources/forum-avatars/defaults/userdefault.png)
January 27, 2012
![sp_UserOfflineSmall](https://forum.prosysopc.com/wp-content/sp-resources/forum-themes/default/images/sp_UserOfflineSmall.png)
Solved this topic by adding a simple ShutdownHook in main method. Btw, I use Tanuki Service Wrapper for starting the server as a service.
@Override
public void run() {
server.shutdown(5, new LocalizedText("OPC-UA Server was shutdown", Locale.ENGLISH));
}
});
Most Users Ever Online: 518
Currently Online:
21 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 142
pramanj: 86
Francesco Zambon: 83
rocket science: 82
Ibrahim: 76
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 704
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1482
Posts: 6316
Newest Members:
samui, TommyDab, wross, Jeremyknock, Pedromon, DonaldEdism, Miguelplese, Scotanine, katesalas95, PetertumModerators: Jouni Aro: 1015, Pyry: 1, Petri: 0, Bjarne Boström: 994, Jimmy Ni: 26, Matti Siponen: 330, Lusetti: 0
Administrators: admin: 1