为了将实时数据库信息推送到客户端,在服务器端使用flask-socketio,通过websocket将所有实时数据库信息推送到客户端。
下面是我的视图文件的一个片段:
from ..models import Host
from flask_socketio import emit, disconnect
from threading import Thread
thread = None
def background_thread(app=None):
"""
send host status information to client
我在网上找到了这个例子。不知怎么的,我不能让它正常运行。我做了很多搜索,但还是找不出是什么错误?!希望有人能帮我弄清楚。
服务器代码:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Tracing;
using HTek.Core.MEF;
using HTek.Core.Server.Web.MEF;
using HTek.Core.Server.
我正在构建一个web接口/数据API,使用烧瓶和Flask进行websocket通信。我想开始转向使用Gevent/Gevent、Gunicorn和最终Nginx来实现负载平衡的更易于开发的设置。但是,在安装Gevent和Gevent之后,在启动SocketIO服务器时仍然会收到一条警告消息:
WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance.
根据酒瓶-SocketIO文件,
当应用程序处于调试模式时,Werkzeug开发服务
根据互联网和中的一些例子,我创建了一个webSocket连接。
public class sockets: IHttpHandler {
public bool IsReusable {
get {
throw new NotImplementedException();
}
}
public void ProcessRequest(HttpContext context) {
if (context.IsWebSocketRequest) {
context.Accept
我有一个痛苦的问题。我使用Flask-SocketIO将后台进程的一些状态更新到网页上。对于我的示例,我的应用程序放在机器A中,IP为170.8.8.8监控端口5000,我将nginx放在机器B中,IP为170.8.8.9也监控端口5000。所以我想访问B中的IP:5000,跳到A中的IP:5000。下面是我在机器B中的nginx配置:
upstream cuitccol.com{ #the name of server cluster
server 170.8.8.8:5000 max_fails=5 fail_timeout=50s; #for the first web