本文介绍了什么是“信息:传输结束(未定义)"?在 Sails.js 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动服务器'sails lift'时,它显示

debug: --------------------------------------------------------
debug: :: Mon May 05 2014 10:59:17 GMT+0700 (ICT)
debug: 
debug: Environment  : development
debug: Port     : 1337
debug: --------------------------------------------------------

info: handshake authorized AUcEOqQtYzXw0jBMiSbp
info: handshake authorized t9Y7k4zozlyXd1nwiSbq
info: transport end (socket end)
info: transport end (undefined)

我想知道最后两行是什么?

info: transport end (socket end)    
info: transport end (undefined)

推荐答案

TL;DR:如果您不想看到这些消息,请先关闭所有已连接到 Sails 应用程序的打开页面/选项卡重新提起.

这些消息来自 socket.io.看起来您正在使用两个打开的选项卡/窗口提升 Sails,这些选项卡/窗口以前通过 websockets 连接到正在运行的 Sails 实例,并在服务器再次启动后重新连接.然而,套接字重新连接后发生了一些意想不到的事情,它们关闭了连接.发生这种情况的原因有很多;例如,如果您在 Sails 中为会话使用内存存储(这是开发模式的默认设置),则旧的套接字连接可能会尝试重新连接并恢复不再存在的会话.没什么好担心的;只要确保在重新启动 Sails 后刷新页面,一切都应该没问题.您很少需要在服务器重新启动之间维护网页的状态,但如果这样做,您可以使用 onConnectonDisconnect 的组合来实现config/sockets.js 中的方法和一些前端逻辑.

Those messages are coming from socket.io. It appears that you're lifting Sails with two open tabs / windows that were formerly connected via websockets to a running Sails instance, and reconnected once the server started again. However, something unexpected happened after the sockets reconnected, and they closed their connection. This can happen for any number of reasons; for example, an old socket connection may try to reconnect and resume a session which no longer exists, if you're using the memory store for sessions in Sails (which is the default for development mode). It's nothing to be concerned about; just make sure you refresh your pages after restarting Sails and all should be well. It's pretty rare that you'll need to maintain state for a web page between server reboots, but if you do, you can do it with a combination of the onConnect and onDisconnect methods in config/sockets.js and some front-end logic.

这篇关于什么是“信息:传输结束(未定义)"?在 Sails.js 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 13:45