question

Upvotes
Accepted
3 1 1 2

OpenDACS: Should I check daemonConnectionState before calling login()?

Following AuthorizationSystem::createAuthorizationAgent(), our code is monitoring AuthorizationAgent::daemonConnectionState() before calling login(). It proceeds to login() only after the state comes to authorizationConnectionUp. However the documentation does not mention checking the state. Sometimes the state is still authorizationConnectionPending even few seconds after the createAuthorizationAgent call. Is it mandatory to check the daemon connection state before calling login()? Is it safe to call login() if the state is still pending?

DACSopen-dacslog-in
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvote
Accepted
82.7k 279 53 77

Yes, the code should check the daemonConnectionState before login().

If the application calls the login when the daemonConnectionState is not up, it may receive the following events.

12:13:21 Received DACS Authorization Event... 
User: user01 Position: 10.0.0.1/net 
Status: LoggedOut 
Status Code: AuthorizationSystemNotAvailable 
Status Text: DACS_UserLogin: Can't login User due to DACS Multiplexer connection down 
DACS Event stream closed 

The event stream has been closed so the application needs to login again to open the stream.

In my opinion, it is not mandatory to check the daemon connection state before calling login() but it is nice to check it to avoid the re-login.

It is safe to call login() if the state is still pending. The key point is that the application needs to handle the stream state properly and check that if the login is opened/closed and LoggedIn/LoggedOut.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.