-
Notifications
You must be signed in to change notification settings - Fork 216
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
Improve connection error handling #49
Comments
Interesting points! May I ask the use-case for making a difference between those two? Is it for debugging/setting up the system, or is it affecting, say, the UI flow (e.g. you want to tell the user where the issue comes from)? Right now it has been almost exclusively used with the backend running on the same device as the language bindings, so the connection to the backend is always fine (unless the backend is not running). So we haven't seen the need to improve this. That's why I am interested in the use-case. This said, there is a way with gRPC to know the state of the channel, so we could possibly do something there. But the thing is that you don't always communicate with the server. As a comparison, say now I am writing this message on my browser. I don't know if my connection to github is still fine; I will only realize once I send the message, right? It's the same with gRPC. When you |
For debugging. I am running the wrapper and the backend on two different machines for performance/compatibility needs (I use MacOS but I've had issues building and running px4/gazebo/mavlink-router/... on anything that isn't Linux). So there is a potentially unreliable network in between. I agree this isn't the envisioned use case. But I can see a real use case where the flight controller fails (ex: hardware failure) and the backend keeps running, and vice versa. In which case I think it is important to differentiate.
I understand. |
I see. Note that you can for sure run both the wrapper and backend on macOS, and SITL on your Linux. I do that a lot with this docker image, but you could just run SITL on Linux and redirect MAVLink to your macOS (by using e.g. mavlink-router or by doing something similar to what I do in my docker image, which is to set
The Would that solve your problem for now? We could also think about a more elegant way to handle that, for sure! But if that's not critical to you, I would rather not put that at the top of my priorities right now (if you want to contribute on that, I can definitely give feedback, though!). |
Sure. However, System.is_connected is not implemented in the current version of the wrapper. I'm also curious about the role of Core.connection_state ? |
So I believe it is what you expect with |
I can't confirm it, because it throws an error whether the connection is established or not:
Yes. I've dug into the generated code and it appears that core.connection_state() returns an object with 2 attributes: the uuid and an is_connected boolean. Sounds good, but what I don't understand is that it does not match the model used in other modules. Each class of the API ref (Info, Telemetry, Action, Mission) has a class with the same name in the wrapper. Except System. |
That may be a bug, let me check that :-)
You're right. The thing is that other modules are "plugins", and Does that make sense to you? |
It does, thanks for the explanation 😄 |
@JonasVautherin any progress? I don't mean to push you, there is no rush. |
Not yet. Should not be a big issue, though. Let me open two issues actually:
And I will close this one, as I believe the current behavior which the gRPC error is usable, just not super elegant. |
One may face 2 types of connection errors:
Right now I see several issues:
Here are some examples:
Backend unreachable (DNS resolution failure):
Backend unreacheable (connection refused):
Identifying errors
If found how to correctly identify the type of error by getting grpc.RpcError._state.code:
But that looks like bad practice. I don't want to have to dig so deep into the dependencies to do proper error handling. Plus I'm not even supposed to use grpc.RpcError._state (private attribute)
Backend reachable but not PX4
I have not found a clean way to verify the connection with PX4 succeeded. A workaround is to try to get data from PX4 and catch an exception. For instance, using get_version() and catching InfoError. The problem is: 1) there could be other reasons for this exception to be raised. 2) there is a delay (timeout?) for the exception to be raised.
Connect() result
The connect() function does not appear to return a result. So in order to know if the connection is established, one has to use other ways like catching telemetry exceptions.
connection_state
I’ve tried 2 things:
The text was updated successfully, but these errors were encountered: