-
Notifications
You must be signed in to change notification settings - Fork 92
SDK doesn't response after sending too much commands in a row / after losing connection for a moment. #37
Comments
Hi, @omeryagmurlu thanks for the info. Sounds like we could accommodate this by attempting a reconnection in that case. Right now we just throw bad response packets away, but do not attempt to clean up the command queue. Perhaps we should throw away all outstanding requests in that case? What behaviour would you expect or like it to have? |
It should attempt a reconnection, clear the queue, and emit an event (reconnection). But attempting to reconnect only when a bad response comes doesn't fix this problem, if noble doesn't even get a bad response, then the queue will fill again. |
I found out that the queue simply gets stuck, I thought that it was at least parsing the zero index each time a new command is sent, but apparently, it doesn't. Here is a simple script
the changes I made to the source code are:
Here is the output:
It goes on but I cut it. Also, the strange thing is, my Ollie is next to my Computer while I run this script. So it can't be "disconnected". |
I was just debugging the same I'm experiencing the same issue here, as my BB8 is dying / becoming unresponsive or not reconnecting at all (just after a few attempts / seconds), after a bad 'command' que. Same as @omeryagmurlu , my BB8 is next to me. |
Thanks for all the detailed info. Also, which OS & node versions are you using, @omeryagmurlu & @dimorphic ? |
@deadprogram Running OSX 10.11.2, and i've tried both Node 4.1.2 and 0.12.0. Atm on 0.12.0. |
@deadprogram Running Ubuntu 15.04 and node versions are 4.2.4 and 4.1.2 |
Running on OS X 10.11.2 (15C50) with Node v5.2.0 here and I'm not able to reproduce the issue. Even by setting a really low timeout (1) in your simple script @omeryagmurlu, the queue quickly fills up but my BB8 device doesn't disconnect. Do you need to run it for a long time? |
There were some improvements in the 0.8.0 release, just wondering @omeryagmurlu & @dimorphic could either or both of you please try again with the latest code? Thanks. |
@dimorphic I am experiencing the same issue. Working with the BB8 suddenly I get: Unhandled rejection Error: Command sync response was lost. for any command I send. And I haven't found the pattern to get it working again. Did you find a way to fix it? I tried hard reset on the platform but it still failing. It seems a matter of time but I would like to understand when this happens and how to recover. I am using: v0.9.2 on Mac OS v10.11.5 with Node v4.4.4 |
Wow, first of all, sorry for missing in action! -.- @debu66er : Looking back at my code (4 months old now, so it might not be up-2-date with latest release), what I ended doing was add a Also, for my examples, I made a process respawner helper, which helped me in reconnecting to my droid and other devices when / if needed. :) I can't really recall if i've made some custom tweaks to my local installed You can check the code at : https://github.com/dimorphic/bb8 Movement throttle helpers (nothing fancy) src/lib/bb8/commands/movement.js#L92 @deadprogram : As soon as i have some free time, gonna try with the latest release and see if there's still an issue. That if this issue wasn't resolved yet and not closed, as I see the release version is |
Hi @dimorphic, thanks for your quick answer.
How I get to this situation? I haven't a clear idea. It is after a while, 10-15 minutes but not sending huge amount of commands. Then it doesn't matter what I do, just a single and isolated command will fail. |
@debu66er Sphero sleeps after (by default) 6 mins of inactivity. Are you sure that your bb8 is awake while you're sending commands? Here is the program I was working on. I hadn't time to check if it still works, but if there hasn't been huge changes to the API, it should work. You can look at the code to see whether youre doing something wrong. Before this repo supported BB8 (bzw. Ollie) I had made a repo to control them. It don't develop it anymore but you can give it a shot. It was working fine last time I checked. |
@debu66er : Indeed, the throttling is just so you don't spam it, killing it. In my examples, i use either an Xbox controller or Myo armband, from which i get a data stream to use for direction / speed on BB8. As i said, i also had some random disconnects back then. Sometimes, suddenly, even after playing for minutes, it would die / disconnect, eventho it was just sitting (no movement commands) and i was just changing colors (one at a time). Can't recall the stack trace error if any. Also, i was running |
Thanks @omeryagmurlu I will check your SDK and give it a try. So what I am not able to understand is why the official app plays with BB8 (so it is answering to commands) and fater that, I connect mine (it connects correctly), I send just a command and I get the error saying BB8 never answered :-/
Checking the source code of that line looks like:
Am I correct thinking that BB8 receives my command but never answers? |
I forgot to paste my simplified test case:
I think it is really simple and correct, isn't it? |
Thanks @dimorphic, so for those specific cases you comment that suddenly it stops working... how did you get the bb8 back? Any tip or trick? Just wait for couple of hours? |
I just restart the whole reconnect process. The droid is not stuck, but only suddenly disconnects and dies, and i'm forced to reconnect. |
Ok @dimorphic, that is not my case. In my case I can connect but any command I send fails with previous exception. Also all examples from the SDK, so it is not my code. |
At the end, I am not able to explain when this issue happens. It seems some how random and related with battery. But I was able to find a not scientific procedure to recover it which is connect() and disconnect() several times from my app previous reset once on the platform. What I see is that when connecting, BB8 executes the commands that failed before. It is like it has memory and as it didn't answered before it is trying to answer now. So after I connect and disconnect several times it seems I clean its queue or whatever it has and it starts working again. Any function to clean, reset or whatever it needs to start from scratch? |
Finally, a ping() call after connect() function avoided any more hanged.
|
hi @debu66er can you please provide a code sample of the ping() call you make after connecting. I am facing the same issue where I am able to connect to the bb8 from OS X, however it is losing the connection after the command is issued and my Nodejs app running in electron is not getting a response back from bb8 and I get the following, even for the ping() command:
EDIT I have also tried to run this from a fresh install on Node inside a pure node project and get the same error:
My current environment is:
|
bb8.connect(function()
{
console.log("##### Connected to BB8");
bb8.ping(); // Workaround for BB8 hangs?
});
…On Wed, Feb 22, 2017 at 8:00 AM, Shah Newaz Khan ***@***.***> wrote:
hi @debu66er <https://github.com/debu66er> can you please provide a code
sample of the ping() call you make after connecting. I am facing the same
issue where I am able to connect to the bb8 from OS X, however it is losing
the connection after the command is issued and my Nodejs app running in
electron is not getting a response back from bb8 and I get the following,
even for the ping() command:
Unhandled rejection Error: Command sync response was lost.
at Sphero.handler (/Users/shah/projects/node/ai8/node_modules/sphero/lib/sphero.js:252:21)
From previous event:
at Sphero.command (/Users/shah/projects/node/ai8/node_modules/sphero/lib/sphero.js:180:10)
at Sphero.device.setRgbLed (/Users/shah/projects/node/ai8/node_modules/sphero/lib/devices/sphero.js:369:12)
at Sphero.device.color (/Users/shah/projects/node/ai8/node_modules/sphero/lib/devices/custom.js:168:19)
at file:///Users/shah/projects/node/ai8/js/orb.js:7:7�[0m
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#37 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIUjWKSOFU1AevvpYq-YSs-c5dTETieYks5re90hgaJpZM4G7b_d>
.
|
Hi @debu66er thanks for your input, I believe I am having a slightly different issue as the response does not come back from the BB8 unit once the command being sent is executed. Therefore once I issue the ping() command after connecting, it is executed however the response does not come back. The issue is in the /Sphero_NPM_Module/lib/sphero.js /**
* Adds a promise to the queue, to be executed when a response
* gets back from the sphero.
*
* @private
* @param {Array} cmdPacket the bytes array to be send through the wire
* @param {Function} resolve function to be triggered on success
* @param {Function} reject function to be triggered on failure
* @example
* sphero._execCommand(packet, resolve, reject);
* @return {void}
*/
Sphero.prototype._queuePromise = function(cmdPacket, resolve, reject) {
var seq = cmdPacket[4];
// ***** I will check the err and packet objects in this function and update *****
var handler = function(err, packet) {
clearTimeout(this.responseQueue[seq].timeoutId);
this.responseQueue[seq] = null;
this.busy = false;
if (typeof resolve === "function") {
if (!err && !!packet) {
resolve(packet);
} else {
var error = new Error("Command sync response was lost.");
reject(error);
}
}
this._execCommand();
};
var timeoutId = setTimeout(handler.bind(this), this.timeout);
this.responseQueue[seq] = {
handler: handler.bind(this),
timeoutId: timeoutId,
did: cmdPacket[2],
cid: cmdPacket[3]
};
}; |
Hi there, Quick description of the issue My Questions Fixes tried Current Config Detailed Description of Issue Fist few commands execute instantly, but then after 10-20 seconds (about 30-50 commands), they suddenly they start lagging up to few seconds long lags and I was getting the same message as mentioned above. Unhandled rejection Error: Command sync response was lost. The error line is in _queuePromise function mentioned above I tried sending commands more often and less often, it made no difference. And I also tried waiting (for example 60 seconds) and then started sending commands. It looks like Sphero starts to lag 10-20 seconds after I start sending commands no matter how many commands I send and how much I waited before. |
Hi all, |
With my Ollie, I am able connect and send/get data to/from Ollie but I have a problem. After noble loses connection with Ollie for a moment,
commandQueue
property ofSphero
constructor fills up quickly and it gets stuck and new commands don't execute on time, (they execute after 1 or 2 min). And the queue is processed when a new command is sent (line 177), so it becomes a vicious circle with no end. One solution I found was to reduce the256
limit to 1, but it defeats the purpose of the queue.The text was updated successfully, but these errors were encountered: