Skype channel proactive message request get 500 (Internal Server Error) after some time

青春壹個敷衍的年華 提交于 2019-12-13 03:51:06

问题


I am developing a bot for Skype channel, which can send proactive messages.

I followed the example project https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/16.proactive-messages , and this works for my need.

I host my bot on a shared hosting service, not Azure.

I registered my bot in Azure Channel Registration, tested on skype. Bot responds to me, and when i send request to proactive endpoint, i get proactive message. Everything is fine.

Then i realized, after some time, proactive request get 500 (Internal Server Error). After that, i typed something to bot from skype, then send proactive request again, bot sended the proactive message.

I investigated this issue, and found two things. First, enable AlwaysOn within IIS, but i am on shared hosting, i can't do that. Second, send some requests to bot regularly to keep bot alive.

Than i noticed, i can do this with DirectLine channel. I set up my code to start conversation, send some message, and receive it before i send proactive notification. It was easy to start conversation from DirectLine, i sended a message, and i received response. Since this is a request to bot, i think this can solve my 500(Internal Server Error) response status with proactive. But it didn't.

I can only receive proactive messages in Skype, only if i type something to bot from skype in short period of time. Otherwise, Skype proactive message request gets 500 error.

I don't know how to get this done.


回答1:


Note that I'm also working with this user in their duplicate GitHub issue.

This sounds like it's possibly a TrustServiceUrl Issue (despite the 500 vs 401 error message).

You can fix it by adding Skype to the list of trusted URLs:

var serviceUrl = <GetThisFrom Activity.ServiceUrl>;

MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);

Here's a link to the library, if that helps. Otherwise, browsing these issues should help.

Note to others:

This "Trust Service URL Issue" doesn't apply to just Skype. This happens for lots of other URLs when trying to use Proactive messaging. Just replace serviceUrl with whatever is appropriate for your use case. And yes, if you're using multiple channels, you can add multiple URLs when using MicrosoftAppCredentials.TrustServiceUrl() by calling it multiple times.

Here's the method definition. Note: you can add expiration for this, as well.

I've submitted a PR for this, which so far has resulted in some updated docs



来源:https://stackoverflow.com/questions/56288134/skype-channel-proactive-message-request-get-500-internal-server-error-after-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!