[英]Flask-SocketIO doesn't work on Azure
I have a website that works perfectly when I host it locally, but on Azure the socketio requests result in an http 400 error. 我的网站在本地托管时运行良好,但是在Azure上,socketio请求会导致http 400错误。 It is a Python flask app that uses flask-socketio. 这是一个使用flask-socketio的Python flask应用程序。 The socket I connect to locally is ' http://127.0.0.1:5000 ,' but on Azure I connect to http://myurl.azurewebsites.net:80 because the Azure documentation says it listens on ports 80 and 443. I'm using javascript with jquery and this is how I create the socket: 我在本地连接的套接字是“ http://127.0.0.1:5000 ”,但是在Azure上,我连接到http://myurl.azurewebsites.net:80,因为Azure文档说它在端口80和443上侦听。正在使用带有jQuery的javascript,这就是我创建套接字的方式:
var socket = io.connect('http://myurl.azurewebsites.net:80');
I've found many questions from people who had this issue, but they all seem to be using node.js, and the solution involves the node.js require() method. 我发现有这个问题的人提出了许多问题,但它们似乎都在使用node.js,解决方案涉及到node.js require()方法。 I can't find a solution using just javascript or jquery. 我找不到仅使用javascript或jquery的解决方案。 Is this even possible? 这有可能吗? Thanks. 谢谢。
I tried to reproduce your issue but failed. 我试图重现您的问题,但失败了。 I followed the sample here . 我在这里关注了样本。 After deploying to Azure, installing the requirements and enabling Web Sockets in Azure portal > App > Application Settings
, it works all fine.Please refer to my components. 部署到Azure后,安装要求并在Azure portal > App > Application Settings
启用Web套接字,一切正常。请参考我的组件。
Output : 输出 :
My web.config : 我的web.config :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<webSocket enabled="true" />
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="D:\home\Python27\python.exe" arguments="run_waitress_server.py" requestTimeout="00:04:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="PYTHONPATH" value="D:\home\site\wwwroot" />
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Hope it helps you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.