Search code examples
c#botframeworkdirect-line-botframework

startConversationAsync() on DirectLine client doesn't finish


I have a bot running on botframework v3. I made a directline channel so that I can parse quests from Alexa and Google Home. These requests go via a webservice that bridges between Amazon cloud/Google cloud, and the botservice. Alexa calls are received on api/alexa, and Google Assistant calls are received on api/Google. I run this in between webservice locally, and therefore I am routing the requests through ngrok with host-headers=rewrite. Alexa works just fine, but Google Assistant doesn't. Somehow the conversation doesn't start. See the code below

Initiating directLine from the Alexa controller (works):

    var client = _directLineMaker.GetClient(ConfigAndConstants.DirectLineSecret);

    var conversation = await client.Conversations.StartConversationAsync();
    session.Attributes[ConfigAndConstants.DictKeyWatermark] = null;

Initiating directLine from the Google controller (doesn't work):

    var client = _directLineMaker.GetClient(ConfigAndConstants.DirectLineSecret);

    /// client is defined
    var conversation = await client.Conversations.StartConversationAsync();
    /// The line below is never reached
    var session = sessionId;

In both cases, _directlineMaker.GetClient() simply returns

    return new DirectLineClient(directLineSecret);

The behaviour is consistent; Google Assistant has never worked, Alexa always works. I don't see what I do differently, and I am clueless to what could cause this behaviour.

What could cause startConversationAsync to not return anything?

Edit:

Starting a conversation for Google Assistant does work when I invoke

var conversation = client.Conversations.StartConversation();

So I am happy. Still puzzled why the async version hangs.


Solution

  • It had nothing to do with directline, but everything with me creating a deadlock. Running this code within Task.Run( () => { } ).Result; solved everything.