-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handle unexpected error in DefaultRegistrationEngine. #933
Comments
Hi @moznion, thx for reporting this 🙏 and sorry for the delay. I think you raise a good point. I looked at you PR #928 and you propose to add a callback. Before to go in this way I would discuss a bit about this. 1. When this happens do we really want to stop the device or we want to reschedule a task ?I suppose that if something unexpected happens this is maybe better to stop the client. 2. Is there something else to do than stopping the client ? in other word do we really need a callback ?
Should we directly stop the client instead of let user to do it ? (I mean stop the client in leshan library not only in leshan-client-demo) 3. if we need a callback maybe we can reuse
|
Thank you for your response, @sbernard31!
Yes, I agree with you. If something unexpected occurred, I suppose it would be better to stop the client than prolonging the lives of the process/task.
This is a good point. I focused on keeping the backward compatibility for the existing client implementation, so I intended to leave users to control the behavior to handle something in an unexpected situation, as a callback.
Ah, yes. I think we can reuse
I'm sorry, I'm not sure where should we add the code execution in |
I suppose If you ask that means you are motivated to provide contribution ? If I'm right please could you do that in several PRs.
About 3, maybe better we could reuse |
Thank you for your information!
Reusing
I have a question about this. Is it prefer to call
|
🎉
By "controllable" you mean "user is able to destroy or not" ? 2 little advises :
|
Thank you for the comment.
Probably no, that's true.
When I read this comment, I thought " However, as you mentioned, it is enough to implement Then, I have a doubt: what should be |
I think you don't get my idea or least not exactly what I have in mind. My point was you implement for each LwM2mObjectEnabler
if LwM2mObjectEnabler implements Destroyable
LwM2mObjectEnabler.destroy() |
Ah, finally I've got it! |
With the solution proposed above, It's an idea. I don't know if this is the best one 😅. |
That's the idea :) |
Thank you. I'm sorry for bothering you because of my misunderstanding. I think that idea is great to introduce the new mechanism to destroy, stop and start with keeping the backward compatibility. This is what we needed definitely ✨ So can I start to implement this feature? |
🚀 ! Please as I said before if you can split it in several PR, this would be better for review :) |
I understand that! Thank you for your help 🙏 |
Just a last question you target Leshan 2.x/master (LWM2M 1.1) or Leshan 1.x(LWM2M 1.0) ? |
That’s a good question. |
Working on |
I agree with you! I’m going to start by |
…-core package Ref: eclipse-leshan#933 (comment) Signed-off-by: moznion <[email protected]>
Move the interfaces `Destroyable`, `Startable` and `Stoppable` to `leshan-core` package from `leshan-server-core`. This commit aims to use these interfaces with `LwM2mObjectEnabler` to control the state of that. Ref: eclipse-leshan#933 (comment) Signed-off-by: moznion <[email protected]>
Move the interfaces `Destroyable`, `Startable` and `Stoppable` to `leshan-core` package from `leshan-server-core`. This commit aims to use these interfaces with `LwM2mObjectEnabler` to control the state of that. Ref: #933 (comment) Signed-off-by: moznion <[email protected]>
Now it calls `destroy()`, `stop()` and `start()` for each LwM2mObjectEnabler instance according to the LeshanClient status. For example, If it calls `LeshanClient#destroy()`, that method calls for each LwM2mObjectEnabler's `#destroy()`. And other methods are also similar. Signed-off-by: moznion <[email protected]>
…2mClientObserver Add an interface method `void onUnexpectedErrorOccurred(Throwable unexpectedError)` into LwM2mClientObserver. This aims to hook a procedure when an unexpected error has been occurred. Signed-off-by: moznion <[email protected]>
…ngine` Call `LwM2mClientObserver#onUnexpectedErrorOccurred()` on `DefaultRegistrationEngine` when it raises `RuntimeException` at task loop. Signed-off-by: moznion <[email protected]>
…r has occurred Signed-off-by: moznion <[email protected]>
To call `LwM2mInstanceEnabler#stop()`, `LwM2mInstanceEnabler#start()` and `LwM2mInstanceEnabler#destroy()` on the associated method, for each enabler if implemented the interface. Signed-off-by: moznion <[email protected]>
Signed-off-by: moznion <[email protected]> Also-by: Simon Bernard <[email protected]>
@moznion, you finished your work on I list here the issue you should face :
|
In my understanding, I finished my work on the
Yeah, I'd like to backport those features to the |
After that I will probably release a 1.3.0 version of Leshan. |
…e and Stoppable Signed-off-by: moznion <[email protected]>
…able, Stoppable) And make a suggestion to use interfaces that are in the `core` package. Signed-off-by: moznion <[email protected]>
…r ObjectEnabler To call each interface method on corresponded `LwM2mObjectTree` method. Signed-off-by: moznion <[email protected]>
…r LwM2mObjectTree And call each interface's method at related method of `LeshanClient`; i.e. `start()`, `stop()` and `destroy()`. Signed-off-by: moznion <[email protected]>
… unexpected erorr This interface extends `LwM2mClientObserver` interface. And make `LwM2mClientObserverAdapter` and `LwM2mClientObserverDispatcher` implement that new interface. This doesn't break the backward compatibility because `LwM2mClientObserver2` is compatible with `LwM2mClientObserver` and each implementing class conceals the difference between `LwM2mClientObserver` and `LwM2mClientObserver2`. Signed-off-by: moznion <[email protected]>
…occurred If a task that are belong to `DefaultRegistrationEngine` raises unexpected `RuntimeException` and the `observer` member variable implements `LwM2mClientObserver2` (instead of `LwM2mClientObserver`), it calls `LwM2mClientObserver2#onUnexpectedError()` hook. The purpose of this hook gimmick is to shutdown the client application mainly. Signed-off-by: moznion <[email protected]>
…client And implements `Destroyable` interface for each threading task that runs with the demo client application. The reason why it doesn't set the hook at `LeshanClient` is to keep the backward compatibility, this means it delegates "what should client do once an unexpected error has occurred" to the users. Signed-off-by: moznion <[email protected]>
Signed-off-by: moznion <[email protected]>
To clarify the version that is going to remove the deprecated interfaces. Signed-off-by: moznion <[email protected]>
Signed-off-by: moznion <[email protected]>
And make a suggestion to use interfaces that are in the `core` package. Signed-off-by: moznion <[email protected]>
To call each interface method on corresponded `LwM2mObjectTree` method. Signed-off-by: moznion <[email protected]>
And call each interface's method at related method of `LeshanClient`; i.e. `start()`, `stop()` and `destroy()`. Signed-off-by: moznion <[email protected]>
This interface extends `LwM2mClientObserver` interface. And make `LwM2mClientObserverAdapter` and `LwM2mClientObserverDispatcher` implement that new interface. This doesn't break the backward compatibility because `LwM2mClientObserver2` is compatible with `LwM2mClientObserver` and each implementing class conceals the difference between `LwM2mClientObserver` and `LwM2mClientObserver2`. Signed-off-by: moznion <[email protected]>
If a task that are belong to `DefaultRegistrationEngine` raises unexpected `RuntimeException` and the `observer` member variable implements `LwM2mClientObserver2` (instead of `LwM2mClientObserver`), it calls `LwM2mClientObserver2#onUnexpectedError()` hook. The purpose of this hook gimmick is to shutdown the client application mainly. Signed-off-by: moznion <[email protected]>
Signed-off-by: moznion <[email protected]> Also-by: Simon Bernard <[email protected]>
And make a suggestion to use interfaces that are in the `core` package. Signed-off-by: moznion <[email protected]> Also-by: Simon Bernard <[email protected]>
To call each interface method on corresponded `LwM2mObjectTree` method. Signed-off-by: moznion <[email protected]>
And call each interface's method at related method of `LeshanClient`; i.e. `start()`, `stop()` and `destroy()`. Signed-off-by: moznion <[email protected]>
This interface extends `LwM2mClientObserver` interface. And make `LwM2mClientObserverAdapter` and `LwM2mClientObserverDispatcher` implement that new interface. This doesn't break the backward compatibility because `LwM2mClientObserver2` is compatible with `LwM2mClientObserver` and each implementing class conceals the difference between `LwM2mClientObserver` and `LwM2mClientObserver2`. Signed-off-by: moznion <[email protected]>
If a task that are belong to `DefaultRegistrationEngine` raises unexpected `RuntimeException` and the `observer` member variable implements `LwM2mClientObserver2` (instead of `LwM2mClientObserver`), it calls `LwM2mClientObserver2#onUnexpectedError()` hook. The purpose of this hook gimmick is to shutdown the client application mainly. Signed-off-by: moznion <[email protected]>
Signed-off-by: moznion <[email protected]> Also-by: Simon Bernard <[email protected]>
Hello,
If the procedure inside of
ClientInitiatedBootstrapTask
,UpdateRegistrationTask
, and/orRegistrationTask
raises an unexpected exception, that exception caught by acatch
clause and it logs that, but that task never works after caught and unfortunately the process still alive.For example, if
registerWithRetry()
that is inRegistrationTask#run()
raises aRuntimeException
, that task never scheduled anymore (i.e. that process does nothing).This behavior makes it a little bit hard to implement a robust LwM2M client. I think it would be better to provide a way to exit when it falls into an unexpected situation.
What do you think about this?
The text was updated successfully, but these errors were encountered: