Closed masyanru closed 5 years ago
I thought the problem with docker container, but today I created the Linux Web App, push python code from another example (https://github.com/microsoft/botbuilder-python/tree/master/samples/45.state-management) to the WebApp, created start.txt with gunicorn --bind 0.0.0.0 --timeout 600 app:app
and you know what? In Bot Emulator working perfectly and I can connect remotely, but in "Test in Web Chat" in Azure Portal I've got the same error "HTTP status code UnsupportedMediaType".
So weird.
@masyanru What steps are you taking to deploy the Linux Web App?
@mdrichardson
az group create --name myResourceGroup --location "westeurope"
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku B1 --is-linux
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <APP_NAME> --runtime "PYTHON|3.7" --deployment-local-git
az bot create --resource-group myResourceGroup --name myPyhtonBot --kind registration --endpoint https://<APP_NAME>.azurewebsites.net/api/messages --appid <APP_ID> --password <PASSWROD>
then created startup.txt gunicorn --bind 0.0.0.0 --timeout 600 app:app
after push the code to the web app
and that's all
Thanks. I'll start debugging and see if I can help.
This might take awhile as this is pretty rare because we almost never see support issues for:
@mdrichardson, could you sync with @daveta as he's also looking into this. Thanks!
@masyanru Figured it out and honestly, took me wayyy longer than I care to admit. You can see that both of the samples that you tried had this issue.
In app.py
, implement this diff:
@app.route("/api/messages", methods=["POST"])
def messages():
"""Main bot message handler."""
- if request.headers["Content-Type"] == "application/json":
+ if "application/json" in request.headers["Content-Type"]:
body = request.json
else:
return Response(status=415)
@axelsrz @daveta
Does my comment above only apply to deployed bots? Just Linux bots?
Basically, what I noticed was that request.headers["Content-Type"]
came in as
application/json; charset=utf-8
...which caused the 415: UnsupportedMediaType
to throw.
As this issue was my only experience with the Python SDK, I'm not comfortable submitting a PR (unless you just want my above changes in each sample), but let me know if you need additional context.
Un-assigning myself from this one.
@axelsrz @daveta Any updates here?
We should take that change in the samples, @mdrichardson if you want to submit the PRs go ahead, if not I can do it.
@axelsrz Would the PR only need that line changed in each sample? I'm comfortable doing that...just haven't work in Python enough to do much else. But if that's all that's needed, let me know and I'll work up a PR.
I'll work on the PR this week
Version
4.5.0b4
Describe the bug
I've built docker container for this example https://github.com/microsoft/botbuilder-python/tree/master/samples/06.using-cards Localy with Bot Framework Emulator everything works fine, but when I am trying to run this container inside Linux Web App in Azure I get "There was an error sending this message to your bot: HTTP status code UnsupportedMediaType" in every channel (WebChat, Telegram, Teams etc.)
btw, if I connect from Bot Framework Emulator to container in Linux Web App - it works.
Dockerfile
[bug]