botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Operation returned an invalid status code 'Gone'

Open dileepkantapop opened this issue 7 years ago • 22 comments

Bot Info

  • Bot Framework SDK Version: 4.3.2
  • SDK Platform: .NET Core 2.2
  • Active Channels: Skype Webchat
  • Deployment Environment: Azure App Service (West US)

I am facing the below issue after deploying the bot. The bot is working fine in the local emulator, but facing issue in skype and webchat (Haven't tested in Facebook).

Code

` LuisApplication luisApplication = new LuisApplication(
                     _configuration["luisAppId"],
                     _configuration["LuisAPIKey"],
                     "https://" + _configuration["LuisAPIHostName"]); ;
        var recognizer = new LuisRecognizer(luisApplication);

        // Issue is with this line.
        RecognizerResult recognizerResult = await recognizer.RecognizeAsync(turnContext, 
 cancellationToken);`

Error Message

Operation returned an invalid status code 'Gone'

Exception

Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models.APIErrorException: Operation returned an invalid status code 'Gone' at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Prediction.ResolveWithHttpMessagesAsync(String appId, String query, Nullable1 timezoneOffset, Nullable1 verbose, Nullable1 staging, Nullable1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable1 log, Dictionary2 customHeaders, CancellationToken cancellationToken) at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.PredictionExtensions.ResolveAsync(IPrediction operations, String appId, String query, Nullable1 timezoneOffset, Nullable1 verbose, Nullable1 staging, Nullable1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable`1 log, CancellationToken cancellationToken) at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeInternalAsync(ITurnContext turnContext, CancellationToken cancellationToken) at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken) at Airlines.Dialogs.AirlinesRootDialog.GetLuisConfigNameAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\XXXX\Bots\XXXXXX-src\Dialogs\XXXRootDialog.cs:line 179 at Airlines.Dialogs.AirlinesRootDialog.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\XXXX\Bots\XXXXXX-src\Dialogs\XXXRootDialog.cs:line:line 69 at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)

dileepkantapop avatar Apr 19 '19 17:04 dileepkantapop

Dileep, one reason this error happens is if the LUIS model hasn't yet been published yet. The 'Gone' is some kind of an indication that the resource being called is not present.

mprabhu11 avatar Apr 20 '19 07:04 mprabhu11

@mprabhu11, I have published LUIS app. if it's not published means how is it working in bot emulator or accessing through API? It has to show same issue in debugging too But that's not the case. Facing issue once I deployed it.

dileepkantapop avatar Apr 20 '19 07:04 dileepkantapop

Ok, hopefully you've made approp changes to the endpoints in your code reflecting the deployed one.

mprabhu11 avatar Apr 20 '19 07:04 mprabhu11

Try a raw query from your browser to match what your code is attempting to call... Something like this:

https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/01234567-89ab-cdef-0123-4567890abdef?subscription-key=fedcba0987654321fedcba0987654321&q='hello'

It should give a legit looking result like:

{
  "query": "'hello'",
  "topScoringIntent": {
    "intent": "Greeting",
    "score": 0.4556272
  },
  "entities": []
}

mprabhu11 avatar Apr 20 '19 08:04 mprabhu11

Hi @dileepkantapop!

'Gone' Errors occur in one of two situations: either as @mprabhu11 mentioned where a LUIS resource has not been published, or 2) something is configured incorrectly in bot file. Given that you say your error is occurring after deploying your bot, please confirm that your have an appropriate 'production' endpoint in your .bot file.

jwiley84 avatar Apr 22 '19 17:04 jwiley84

@jwiley84 I am trying to access LUIS appid, apikey and hostname from appsettings.json. Which is causing the error after deploying.

dileepkantapop avatar Apr 22 '19 17:04 dileepkantapop

I see! Let me see if I can repro this for you.

jwiley84 avatar Apr 24 '19 16:04 jwiley84

what does this resolve to:

"https://" + _configuration["LuisAPIHostName"]);

To get a LuisApplication, you only need to pass in the AppId, the AuthoringKey and the Endpoint. The Endpoint is simply

"https://" + YOURLUISAPPREGION + "api.cognitive.microsoft.com"

For example, my Luis app is in WestUS, so my endpoint is https://westus.api.cognitive.microsoft.com

jwiley84 avatar Apr 24 '19 21:04 jwiley84

@jwiley84 LuisAPIHostName has westus.api.cognitive.microsoft.com, at last, the URL will be same as which you mentioned https://westus.api.cognitive.microsoft.com.

dileepkantapop avatar Apr 25 '19 07:04 dileepkantapop

What is returned when you use a debugger on this:

var recognizer = new LuisRecognizer(luisApplication);

jwiley84 avatar Apr 25 '19 13:04 jwiley84

In debugging it's working fine when I keep ngrok from my local machine. recognizer returned the variable it's created "Microsoft.Bot.Builder.AI.Luis.LuisRecognizer".

dileepkantapop avatar Apr 26 '19 07:04 dileepkantapop

and just to confirm, the following does not return null:

LuisApplication luisApplication = new LuisApplication(
                     _configuration["luisAppId"],
                     _configuration["LuisAPIKey"],
                     "https://" + _configuration["LuisAPIHostName"]);

jwiley84 avatar Apr 26 '19 16:04 jwiley84

Hi @dileepkantapop Please let me know what the luisApplication is returning, or let me know if you are no longer having this issue.

jwiley84 avatar May 07 '19 15:05 jwiley84

@jwiley84 Sorry for the late, luisApplication is not returning null, It's creating the variable.

dileepkantapop avatar May 07 '19 15:05 dileepkantapop

AFAIK, the only thing that can cause a 'Gone' error is a malformed request to the LUIS service. LUISRecognizer has an option where you can pass in a string of the LUIS endpoint. What happens if you pass it in manually?

var luisService = new LuisRecognizer("https://<YOURLUISREGION>.api.cognitive.microsoft.com/luis/v2.0/apps/<YOURLUISAPPID>?subscription-key=<YOURLUISKEY>");

jwiley84 avatar May 14 '19 21:05 jwiley84

@jwiley84 If I pass the values manually, I am able to get the response.

dileepkantapop avatar May 14 '19 21:05 dileepkantapop

Ok, good. Sorta. That means it's not a problem with your LUIS. Can you post an image of your debugger running on the luisApplication, with it expanded? Like this: image

Somehow, your keys aren't coming through your appsettings.json like they should. luisApplication is just a form of container for essentially what's in the LUIS endpoint string. In fact, if you pass in a string, the constructor just goes back and makes a luisApplication out of it.

jwiley84 avatar May 15 '19 16:05 jwiley84

Hi @dileepkantapop

Just checking if you still have this issue.

jwiley84 avatar May 22 '19 22:05 jwiley84

Closing issue. If this issue persists or begins occurring again, please reopen issue.

jwiley84 avatar May 23 '19 17:05 jwiley84

I faced similar issue, issue with Luis configuration, follow below steps. MANAGE>Application Information>Make endpoint public Check this option and make your endpoint public.

amitkadu avatar Jan 07 '20 18:01 amitkadu