问题标签 [engine.io]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
node.js - Socket.io / Node.js:来自客户端的套接字连接“值超出范围”
我正在努力让 nodejs / socket.io / express 在 ARMv5TE 处理器上的 busybox linux 上运行。我已经启动并运行了 nodejs,并且以下代码运行没有错误。
直到我尝试从客户端通过 websocket 连接。从浏览器(socket.io.js
加载了客户端脚本),var socket = io.connect('ws://192.168.1.8:3000');
或var socket = io.connect('http://192.168.1.8:3000');
. 然后 Node 将此错误记录到控制台并停止:
从我的台式计算机(Windows 8 64 位)运行相同的节点服务器,不会产生此错误。
我可以将错误追溯到以下代码行node_modules/socket.io/node_modules/engine.io/node_modules/base64id/lib/base64id.js
:
如果我更改rand.writeInt32BE(this.sequenceNumber, 11);
为rand.writeInt32BE(this.sequenceNumber, 11, true);
,错误就会消失,我可以继续没有问题(大概)。所以:
- 为什么在 ARMv5TE 机器上运行我的代码时会出现此错误?
- 我的更改是
base64id.js
安全的还是适当的?
android - 启用“桌面视图”时,engine.io socket.io 在 android 浏览器中不起作用
使用各自的示例代码尝试了 engine.io 和 socket.io。
一切正常,除了在安卓浏览器(例如 Galaxy S3 或 Acer A200)上,当我启用桌面视图时它不起作用。
我正在尝试调试它,但我对整个领域都是新手。如果你们中的任何一位专家有一些提示是否值得尝试修复,我将不胜感激。
我在控制台日志中收到一条消息,上面写着:
套接字探测传输“%s”因错误而失败:%s +75ms。(我猜我在调试模式方面也有一些问题,因为我没有看到“%s”解决)
如果不调用调试,我只会在控制台中收到“WebSocket 在建立连接之前关闭”错误消息。
此消息出现大约需要 65 秒,在此之前我看到了一堆不同的尝试“pollin-xhr ...”等。
根据我在网上找到的内容,在浏览器上启用“桌面视图”时唯一的区别是不同的 UA 字符串。情况似乎并非如此。
我想我可以开始数据包嗅探并尝试缩小范围,但我不确定结果会是什么以及是否值得付出努力。有什么想法吗?
socket.io-1.0 - Socket.io 客户端在侦听器函数中抛出错误时重新连接(不显示错误!)
当我在侦听器函数中抛出错误时;
套接字重新连接,并且永远不会显示错误。相反,engine.io Tranport 类会引发“解析器解码错误”。
这样我就无法开发/调试侦听器函数中的逻辑。有解决方案/解决方法吗?
koa - Node.js http.createServer 抛出 TypeError: listener must be a function
index.js:
跑:node --harmony index
和错误:throw TypeError('listener must be a function');
ember.js - Ember.js - 如何从初始化程序转换到另一条路线?
我正在使用初始化程序连接到套接字服务器。经过一段时间后,我想重定向到另一条路线(处理错误)。
如何从初始化程序执行此操作?
当前代码如下:
node.js - socket.io 是否将传输从轮询升级到 websocket ?
我正在使用带有 socket.io 的 nodejs 和 express 框架。以下是我运行命令时得到的日志输出
以下是日志输出。
我没有看到任何确认传输升级的日志消息。乒乓消息也不断发生。
这是否意味着 websocket 传输已建立?
node.js - 安装engine.io节点js时的问题
我正在尝试安装engine.io
(https://www.npmjs.com/package/engine.io)
我收到以下错误:
在此之后我尝试执行这个 js 脚本
我收到这个错误
C:\Windows\system32>node "c:\users\user\documents\visual studio 2010\Projec ts\nodes\WebApplication1\NodeFiles\engineTest.js"
module.js:338
throw err;
^
错误:
在
Function.Module._load (module.js:278:25)
在 Module.require (module.js: 365:17)在对象
的要求(module.js:384:17)
。(c:\users\user\documents\visual studio 2010\Projects\node\WebApplication1\NodeFiles\engineTest.js:1:76)
在 Module._compile (module.js:460:26)
在 Object.Module._extensions ..js (module.js:478:10)
在 Module.load (module.js:355:32)
在 Function.Module._load (module.js:310:12)
在 Function.Module.runMain (module.js:501:10)
-------------------------------------------------- ----------------------
其实我觉得我做的不对。让我解释
首先,我认为engine.io
正如你们所有人所建议的那样,安装是正确的。
现在,当我尝试"var engine = require('engine.io');"
从节点控制台运行命令时,它可以完美运行,并且引擎变量已用数据实例化。
当我检查引擎时,它显示给我。
但是,当我在 JS 文件中写入该行,然后尝试使用 node 命令运行它时,它会中断。错误
我想我在做一些愚蠢的事情。
有人可以帮我吗?
node.js - Windows 8.1 上带有 npm 的 Socket.io
我不想在 Windows 8.1 上安装带有 npm 2.7.4、节点 0.12.2 的 socket.io 并得到这个错误:
modules\engine.io-client\node_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(518):错误 C4430:缺少类型说明符 - 假定为 t。注意:C++ 不支持 default-int [C:...\websocket\node_modules\socket.io\node_modules\so cket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.v cxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(490): 错误C2065:“请求”:未声明的标识符 [C:...\websocket\no de_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation。io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(571):错误 C2065:'NanAsyncExecute':未声明的红色标识符 [C:...\webs ocket\node_modules\ socket.io\node_modules\socket.io-client\node_modules\engine。io-client\node_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m odules\ws\ node_modules\nan\nan.h(571): 错误 C2065: 'uv_after_work_cb' : 未声明的标识符 [C:...\web socket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine .io -client\node_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(769): error C2065: 'AsciiValue' : undeclared我标识符 [C:...\websocket \node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxproj] C:...\ websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(769):错误C2146:语法错误:缺少'; ' 在标识符“值”之前 [C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modu les\engine.io-client\node_modules\ws\build\validation.vcxproj] C:. ..\websocket\node_modules\socket.io\node_modules\socket。io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(769): error C3861: 'value': identifier not found [C:...\websocket\node_m odules \socket.io\node_modules\socket.io-client\node_modules\engine.io-client\no de_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket .io-client\node_modules\engine.io-client\node_m odules\ws\node_modules\nan\nan.h(817): 警告 C4267: 'argument' : 从 'size_t' 转换为 'int',可能丢失数据 [C:\Users...\websocket\node_modules\socket.io\node_modules\socket. io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro j] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。io-client\node_m odules\ws\node_modules\nan\nan.h(829):警告 C4267:'argument':从 'size_t' 转换为 'int',可能丢失数据 [C:...\websocket \node_modules\socket.io\node_modules\socket。io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro j] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。 io-client\node_m odules\ws\node_modules\nan\nan.h(832): error C2065: 'value': undeclared identifier [C:...\websocket\node _modules\socket.io\node_modules\socket. io-client\node_modules\engine.io-client\ node_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。io-client\node_m odules\ws\node_modules\nan\nan.h(858):警告 C4267:'argument':从 'size_t' 转换为 'int',可能丢失数据 [C:...\websocket \node_modules\socket.io\node_modules\socket。io-client\node_modules\engine.io-client\node_modules\ws\build\validation.vcxpro j] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。 io-client\node_m odules\ws\node_modules\nan\nan.h(873): error C2065: 'value': undeclared identifier [C:...\websocket\node _modules\socket.io\node_modules\socket. io-client\node_modules\engine.io-client\ node_modules\ws\build\validation.vcxproj] C:...\websocket\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine。0.1,调试@1.0.2,socket.io-parser@2。2.2) ├── socket.io-parser@2.2.4 (isarray@0.0.1, debug@0.7.4, component-emitter@1.1.2, benchmark@1.0.0, json3@3.2.6) ├── engine.io@1.5.1 (base64id@0.1.0, debug@1.0.3, engine.io-parser@1.2.1, ws@0.5 .0) └── socket.io-client@1.3.5 (到-array@0.1.3, indexof@0.0.1, component-bind@1.0.0, debug@0.7.4, backo2@1.0.2, object-component@0.0.3, component-emitter@1.1.2, 有-binary@0.1.6, parseuri@0.0.2, engine.io-client@1.5.1) 0.1,调试@1.0.2,socket.io-parser@2。2.2) ├── socket.io-parser@2.2.4 (isarray@0.0.1, debug@0.7.4, component-emitter@1.1.2, benchmark@1.0.0, json3@3.2.6) ├── engine.io@1.5.1 (base64id@0.1.0, debug@1.0.3, engine.io-parser@1.2.1, ws@0.5 .0) └── socket.io-client@1.3.5 (到-array@0.1.3, indexof@0.0.1, component-bind@1.0.0, debug@0.7.4, backo2@1.0.2, object-component@0.0.3, component-emitter@1.1.2, 有-binary@0.1.6, parseuri@0.0.2, engine.io-client@1.5.1)
在评论中查看解决方案
socket.io - engine.io-client 中的 forceNew
我想用多个连接测试我的 engine.io 服务器。我正在尝试循环打开套接字,但输出只有一个套接字。
在 socket.io-client 中,我添加forceNew: true
并修复了该问题,但不适用于 engine.io-client。
node.js - engine.io / engine.io-client:不发生传输切换
我在服务器端写了这个:
我写了这个客户端:
它永远不会成功连接!只需 1 次尝试然后回调错误。
它应该在失败时切换协议(从'websocket'
到)。'polling'
为什么不发生协议切换?我们怎样才能使这种转换工作?
详情:
当我transports
在服务器和客户端上使用相同的值时,它可以正常工作;即连接良好且快速且仅当 时才基于 websocket transports[0x0] === 'websocket'
,并且连接也良好且仅当 时才基于轮询transports[0x0] === 'polling'
。
一旦连接失败,就不会使用备用传输重试。
使用 engine.io 1.5.4。