Skip to content
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

rosbridge stops spinning after a service is called #650

Closed
kenji-miyake opened this issue Sep 25, 2021 · 9 comments · Fixed by #666
Closed

rosbridge stops spinning after a service is called #650

kenji-miyake opened this issue Sep 25, 2021 · 9 comments · Fixed by #666
Labels

Comments

@kenji-miyake
Copy link
Contributor

Description

Since rosbridge stops spinning, it can't receive the response here. prewrite_message function seems to be not running.

  • Library Version: bc06a8d (latest ros2 branch at 25 Sep)
  • ROS Version: ROS2 Galactic
  • Platform / OS: Ubuntu 20.04

Steps To Reproduce

Please see tier4#8.

Expected Behavior

  • rosbridge can send a service call request to clients.
  • rosbridge can receive the response of the service call.

Actual Behavior

  • rosbridge can't send the request.
  • rosbridge can't receive the response.
@kenji-miyake
Copy link
Contributor Author

FYI

  • If I add IOLoop.instance().start() after here, it can send the request, but it of course causes another error.
  • We quickly modified this here, but I believe there is a better way to solve this, so I'd like to discuss it.

@jtbandes
Copy link
Member

I believe there is a better way to implement the service call handler. Internally, the Service system seems to support async functions being used for the callback: https://github.com/ros2/rclpy/blob/38a408867719cb76c4b4f0b1caaf9cc191336970/rclpy/rclpy/executors.py#L369 Hopefully this will allow us to remove the while ...: sleep() loop and maybe the lock.

@jtbandes
Copy link
Member

jtbandes commented Oct 12, 2021

Here's some ideas for an alternative implementation than #652: #666 What do you think?

@kenji-miyake
Copy link
Contributor Author

@jtbandes I'm sorry to be late. Yes, it looks good to me and worked for my use case!

@Stephenjerry
Copy link

@jtbandes hi, bro, I found a another issue when I use your branch, that is when I disconnect my client with rosbridge websocket server, then I reconnect my client to server, there will an error displayed "[rosbridge_websocket]: WebSocketClosedError: Tried to write to a closed websocket" any time when I call a service, so any solution to that??? Thanks so much. I just wondered the previous websocket connection is still be using with closed status. Is that right?

@jtbandes
Copy link
Member

@Stephenjerry that's interesting, sounds like something we could write a test for, would you be able to add the scenario you describe to advertise_service.test.py?

@Stephenjerry
Copy link

I just solved it, my buddy, I deleted a line of code, then everything worked ok. A line of code that should be deleted is " self.protocol.external_service_list[service_name].service_handle.shutdown(
"Duplicate advertiser."" in advertise_service.py script.

@Stephenjerry
Copy link

I think this line of code doesn't make any sense, and it seems like blocking the reconnection pipline of same client, so that should be the matter. Do you think so? Or you can try it out like what I described above. Anyway, thank you so much, my bro

@Stephenjerry
Copy link

@jtbandes

jtbandes added a commit that referenced this issue Nov 29, 2021
Fixes #650 (closes #652). Adds a test to show that multiple service calls can be handled concurrently.
jtbandes added a commit that referenced this issue Nov 29, 2021
**Public API Changes**
None

**Description**
Fixes an issue reported by @Stephenjerry in #650 (comment). When a duplicate service is advertised by the client, the code now correctly shuts down the original service.

There is still a `WebSocketClosedError` received with only a single client, when it advertises a service and then disconnects. Filed #684 to track this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants