服务端推送技术

服务端实时推送技术之SSE(Server-Send Events) 服务端推送,也称为消息推送或通知推送,是一种允许应用服务器主动将信息发送到客户端的能力,为客户端提供了实时的信息更新和通知,增强了用户体验。 阅读详情

实现服务端推送的主要技术有:Comet,WebSocket、SSE(Server Send Events)、Bayeux protocol。

   

Comet技术细分

  • 隐藏的iframe streaming,依赖浏览器行为,(可能导致浏览器一直显示加载中,用户体验差)
  • XHR streaming,依赖浏览器行为
  • XHR long polling(同源限制,不能访问其他站点)
  • script tag long polling,可以跨站,实现复杂

   

SSE是单向的,而WebSocket是双向的。

   

Bayeux protocol基于Comet-mechanism,支持streaming和long polling

基于Bayeux protocol的实现有CometD、Faye.

   

WebSocket的握手基于upgrade HTTP连接

   

Jetty8+,Nginx支持WebSocket,另外一些技术有SockJs, Socket.io等(都有客户端和服务端实现)。

   

实现服务端推送系统时,需要考虑的问题有:并发连接、移动客户端的网络不稳定问题等。

   

并发连接的处理

  • 高并发服务器,如Nginx,Jetty, Nodejs
  • 集群部署时,注意client-server连接映射的维护,后端需要将消息推送到client连接的服务器。

   

针对移动客户端的网络不稳定问题,可能需要客户端心跳。不论什么客户端,为了应对NAT,client可能需要心跳。

   

另外,通过消息中间价系统如activemq、rabbitmq结合STOMP协议(可能基于websocket)、amqp协议(例如amqp.js, node-amqp)等可以实现pub/sub。

   

使用Adobe Flash 和后端简历 TCP连接,在Javascript的控制下进行双向通信。需要注意的是防火墙的问题。

   

SPDY的服务器启动流特性,也可以用于消息推送。

   

对于IOS、android等手机客户端可以考虑使用XMPP、ampq协议等。

   

 参考资料

http://www.slideshare.net/PeterREgli/comet-websockets-html5

http://en.wikipedia.org/wiki/Push_technology

   

 

别再模拟IIC了!用STM32F103C8T6的硬件IIC驱动AT24C64,CubeMX配置+避坑指南 本文详细介绍了如何使用STM32F103C8T6的硬件IIC驱动AT24C64 EEPROM,通过CubeMX配置和HAL库函数解析,提供从模拟IIC到硬件IIC的完整解决方案。内容包括硬件IIC与模拟IIC的核心差异、CubeMX工程配置详解、HAL库驱动实战以及典型问题诊断与优化,帮助开发者构建更稳定高效的存储系统。 阅读详情

相关推荐

MobaXterm结合SSH密钥对安全连接阿里云ECS的实战教程

本文详细介绍了如何使用MobaXterm结合SSH密钥对安全连接阿里云ECS的实战教程。通过对比传统密码登录的风险,重点讲解了密钥对的生成与配置、阿里云控制台的密钥绑定技巧,以及MobaXterm的高级设置和故障排查方法,帮助用户实现高效、安全的远程连接。

weixin_29208327的博客 469

网络传输的粗略解释以及WebSocket的使用

WebSocker协议演变 在webSocket协议出现之前,客户端服务器端的链接也进行多次演变 最开始的短轮询 Polling 阶段 客户端和服务器端会一直进行链接,每隔一段时间都会进行询问 频繁的使用ajax来进行轮循 改进版的长轮询 Long polling 阶段(Comet Long polling) 客户端发送 HTTP 给服务器之后,有没有新消息,如果没有新消息,就...

l1076089424的博客 342

从星形到三角形:永磁同步电机FOC+SVPWM控制的相位偏移与扇区重构

本文深入探讨了将FOC+SVPWM控制方案从星形接法永磁同步电机移植到三角形接法时遇到的核心挑战。文章重点解析了由绕组连接方式差异导致的30度相位偏移问题,并详细阐述了如何为此重构扇区判断逻辑、矢量作用时间计算以及电流采样变换,为工程师提供了从理论到实践的完整移植指南。

ujm5678901的博客 547

面试官:服务端推送到Web前端有哪几种方式?

上面实现了5种推送的方案,弄了一个表格简单对比一下方案(准)实时单次连接自动重连断线检测双向推送无跨域短轮询❌❌➖✅❌❌长轮询✅❌➖✅❌❌SSE✅✅✅✅❌❌WebSocket✅✅❌✅✅✅iFrame✅✅❌❌❌❌最近还整理一份JavaScript与ES的笔记,一共25个重要的知识点,对每个知识点都进行了讲解和分析。能帮你快速掌握JavaScript与ES的相关知识,提升工作效率。有需要的小伙伴,可以点击下方卡片领取,无偿分享。

老司机的后备箱 2880

Xilinx Vitis arm-xilinx-eabi-gcc.exe: error: *.c: Invalid argument

This problem may be a bugof version 2021.1 only. Unfortunately, I'm just currently using this version. After Build Project: Find where this Makefile is through "make: Leaving directory" information. For me, it is located atZynq_CPU_wrapper_hw_platfo...

Ayka的博客 6663

STM32F103ZE精英板驱动ESP8266与DHT11构建物联网网关,实现乐联网温湿度数据实时监控

本文详细介绍了如何使用STM32F103ZE精英板驱动ESP8266与DHT11构建物联网网关,实现乐联网温湿度数据实时监控。从硬件选型、连接调试到乐联网平台配置和STM32程序开发,提供了完整的实现步骤和常见问题解决方案,适合物联网入门开发者参考。

weixin_30823001的博客 80

服务端推送-SSE

常见从服务端获取数据的方式有很多轮询(长/短方式)就是客户端按照一定的频率定期向服务器获取数据,兼容性很好。Comet主要获取数据的方式是长轮询和 iframe 流,不管是哪种都是通过建立长链接来使得服务器发送消息给客户端,前者使用轮询(每次轮询时候会一直等待直到服务端返回数据才关闭连接),后者使用页面的 iframe 标签的 src 属性向服务端建立长连接来获得数据。不过后期出现的 WebSocket 有取代 Comet 的趋势。WebSocket。

ahao' Blog 1107

实战案例:用多智能体系统模拟房地产市场的架构设计

房地产市场是典型的复杂自适应系统:买方纠结“要不要上车”、卖方盘算“挂多少钱能快速成交”、中介忙着“撮合两边赚佣金”、政府琢磨“怎么调政策稳房价”——每一个参与者的微小决策,最终都会汇聚成“房价暴涨”“成交冰点”这样的宏观现象。传统的计量经济学模型(比如线性回归)假设“所有人都是理性人”,但现实中没人能算清所有变量——你可能因为“同事买了学区房”就跟风,也可能因为“怕失业”而放弃买房。这时候,多智能体系统(MAS)

移动开发前沿的博客 1125

服务器主动推送消息数据给客户端

1 引言 这个问题第一次是我在实现一个导师的方案的时候所发现的,一开始我需要实现服务器与客户端的密钥协商和数据传递,服务器需要主动分发(推送)密钥给客户端,因为以前没有做过相关编码,后来只能想到用反向连接,也就是交换C/S的身份。 再后来是在做一个机器学习的问题时候,因为机器学习模型的运行需要综合多个客户端(边缘节点)的数据,然后得到结果,而且各个客户端的数据传输是不一致的,时间和数据量不定。...

answer3lin的博客 3万+

【SMPL简介】SMPL: A Skinned Multi-Person Linear Model【源码复现】

SMPL是一种3D人体建模方法.在数字人或者人物角色三维重建领域有着广泛应用支持人体的各种形状及动作可以简单理解为通过训练获取的人物模型SMPL 输入是:姿态shape vectorβ\betaβ+ 影响动作Pose的参数θ\thetaθ输出是: 各种变化后vertex顶点的数据作者:Loper, Matthew and Mahmood, Naureen and Romero, Javier and Pons-Moll, Gerard and Black, Michael J.

zik的博客 3370

本地部署中文LLaMA模型实战教程,民间羊驼模型

LLaMA大部分是英文语料训练的,讲中文能力很弱。如果我们想微调训练自己的LLM模型,基于一个大规模中文语料预训练的模型比较好。目前开源项目很多,理想的项目要有以下特点:模型开源、训练代码开源、代码结构简单、环境容易安装、文档清晰。经过寻找与试验,我找到了一个比较好的项目。本博文要点如下:1 实战部分:模型下载与参数合并、模型命令行加载测试、模型部署为web网页(解决了一些报错问题)2 代码走读:模型参数合并、词表扩充3 原理分析:预训练与指令精调。

artistkeepmonkey的博客 8175

【推送】主流的服务端推送技术的对比

以下是主流的服务端推送技术的对比表格,涵盖WebSocket、Server-Sent Events (SSE)、Long Polling、HTTP/2 Push和Comet:

白萝卜弟弟的专栏 602

第 8 篇:TMC2240 电机正反转实现|DIR 引脚控制 + 代码优化(稳定不抖动)

本文详细介绍了TMC2240电机驱动芯片的正反转实现方法,重点解决方向切换时的抖动和冲击问题。文章首先明确了硬件连接、基础配置和使能状态三个前提条件,然后阐述了DIR引脚电平控制方向的核心原理,提供了STM32的GPIO配置代码。针对方向切换时的电流冲击问题,作者提出了"停止-延迟-切换-启动"的平滑切换逻辑,并给出了包含方向枚举、转速控制和方向切换函数的完整代码实现方案。通过这种优化方法,可以有效避免电机在正反转切换时产生的抖动、冲击声和发热问题,实现稳定的双向控制。文章还提示了后续可

BackCatK Chen的博客 2081

服务端推送常用技术介绍

简介: 服务端常用推送技术介绍,如websocket,sse轮询等 1、客户端轮询:ajax定时拉取 2、服务端主动推送:WebSocket(实时,服务器数据变化推送数据) 全双工的,本质上是一个额外的tcp连接,建立和关闭时握手使用http协议,其他数据传输不使用http协议, 更加复杂一些,适用于需要进行复杂...

enjoy.day 706

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

服务端推送技术的现代实现(8613)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 954

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

服务端推送技术的现代实现(9772)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 723

服务端推送常用技术

服务端推送常用技术 客户端轮询的方式:通过ajax定时拉取,setinterval 服务端主动推送:webSocket,全双工的,本质是一个额外的tcp连接,建立和关闭时握手使用http协议,其它数据传输不使用http协议,更加复杂一些,适用于需要进行复杂双向数据通讯的场景(推荐) 服务端主动推送,SSE(Server Send Event),html5新标准,用于从服务端实时推送数据到浏览器端...

meihao3218的博客 344

服务端推送技术的现代实现(5781)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 533

服务端推送技术的现代实现(8427)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 762

服务端推送技术的现代实现(7222)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 968

服务端服务端推送技术介绍

服务端推送技术,作为客户端与服务器端实时交互的解决方案,经常用于一些实时性要求高的Web应用系统中。目前,经常使用的两项服务端推送技术有Comet和Websocket。 一、Comet技术模型 在Websocket出现之前,Comet是最主要的服务端推送技术。众所周知,超文本传输协议是一种请求/响应协议。HTTP定义了三个对象,分别是客户端,代理和服务端。客户端通过和服务端建立连接来发送HTT...

qq_27215113的博客 507

服务端推送技术的现代实现(2772)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 744

服务端推送技术的现代实现(4950)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 869

服务端推送技术的现代实现(9337)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 476

服务端推送技术的现代实现(1044)

Hyperlane is a lightweight and high-performance Rust HTTP server library designed to simplify network service development. It supports HTTP request parsing, response building, TCP communication, and redirection features, making it ideal for building modern

m0_52796585的博客 386
上一篇: Faye,Simple pub/sub messaging for the web
下一篇: 性能优化需要注意的点
iCode0410
博客等级 码龄14年 6粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值