i8beef / HarmonyHub

Library for controlling a Logitech Harmony Hub
MIT License
23 stars 7 forks source link

Timeout on every ping #11

Open spudwebb opened 5 years ago

spudwebb commented 5 years ago

Hi,

I'm using the TestClient console application. Everytime the program tries to Ping the harmony hub I get a timeout. If I try to add the ping request as an interactive command like this:

                    switch (input)
                    {
                        case 'p':
                            await client.SendPingAsync();
                            break;
                        case 'a':
                            var activityId = await client.GetCurrentActivityIdAsync();
                            Console.ForegroundColor = ConsoleColor.Yellow;

it works fine other requests work fine too

the problem looks like some kind of deadlock related to calling the SendPingAsync from the timer event handler, but I cannot pinpoint what is the exact problem.

I checked with WireShark that the ping request is actually sent and that the hub answers it. And everything seems fine. but the _reader.Read() in NextElement never returns.

Do you have the same problem? Do you have any idea what's wrong?

i8beef commented 5 years ago

Not off hand no. This is working fine from what I can tell in HomeAutio.Mqtt.Harmony... Do you still get it if you change the ReadKey to a ReadLine at the end of the TestClient while loop? Or add a Console.WriteLine() outside of the main using statement (before the timer is created)?

Going off this here: https://stackoverflow.com/questions/15679683/console-readkey-vs-console-readline-with-a-timer

spudwebb commented 5 years ago

same results with both changes

i8beef commented 5 years ago

Hmm well Im not really sure. Ill have to play with it when I get some time. The fact that this is working just fine in non-interactive services means I'm not too worried about it. The test app is just a harness to play with and verify functionality. I suspect it has something to do with the timer completions actually finishing due to the interactive console IO.