我对大气很陌生。到目前为止,我已经设法为我现有的Tomcat 8+ Spring + Struts2 web应用程序添加了气氛。我使用了当前版本(氛围-运行时2.4.24,气氛-弹簧2.4.20和atmosphere.js 2.3.5)。
对于某种简单的状态页,我已经设法使SSE传输正常工作。使用谷歌Chrome或Mozilla,这是非常好的工作。我喜欢它!在实现了这一功能之后,我想检查无法实现SSE (Internet和Edge)的浏览器的回退。在客户端日志中,我可以看到氛围可以很好地检测到SSE特性的缺失,并使用回退:
Server Side Events(SSE) is not supported, using request.fallbackTransport (long-polling)
atmosphere.js (3272,21)
Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 2
atmosphere.js (3272,21)
Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 3
atmosphere.js (3272,21)
Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 4
atmosphere.js (3272,21)
Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 2
atmosphere.js (3272,21)
Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: Firing onOpen
atmosphere.js (3272,21)
Atmosphere connected using long-polling
utils.js (879,3)
Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: Firing onOpen
atmosphere.js (3272,21)
Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 3
atmosphere.js (3272,21)但是,即使我可以调试服务器端并看到消息正在写入AtmosphereResource,也没有数据到达客户端。我就是这样在客户端初始化气氛连接的:
request = {
url: '<s:url value="/public/sse/ci" />',
contentType: "application/json",
method: 'POST',
logLevel: 'debug',
transport: 'sse',
reconnectInterval: 5000,
fallbackTransport: 'long-polling'
};有人能给我一个正确方向的提示吗?
致以亲切的问候,
塞巴斯蒂安
发布于 2018-05-29 13:45:26
好吧。
我终于让它起作用了。与this stackoverflow question一样,我在服务器配置中添加了TrackMessageSizeInterceptor,但在客户端配置中没有添加。也许其他人来这里读答案。
https://stackoverflow.com/questions/50502972
复制相似问题