无法在本地扩展socket.io,这很可能是因为会话存储

时间:2012-02-04 12:15:18

标签: session node.js websocket redis socket.io

我有一个主进程,它使用集群模块,当然还有socket.io来分配所有socket.io服务器的工作者。

问题在于,除非我特别说我只想要一个工人,否则我的代码就不起作用了。我在集群模块存在之前编写了它,它作为一个单独的进程工作正常,现在看来它是一样的。

使用RedisStore作为会话存储分叉4个工作人员(cpu核心数)的情况如下:

node_redis: no callback to send error: Error: ERR wrong number of arguments for 'hset' command
Caught exception: Error: Error: ERR wrong number of arguments for 'hset' command

如果我使用默认的MemoryStore,则在socket.io日志中不断重复

   debug - cleared close timeout for client 3883988821204831830
   debug - discarding transport
   debug - client authorized
   info  - handshake authorized 12039436321106971132
   debug - xhr-polling received data packet �43�5:::{"name":"estimatepp","args":[70821530]}�20�5:::{"name":"ready"}
   debug - setting request GET /socket.io/1/xhr-polling/217474157959916242?t=1328357263590
   debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing 7:::1+0
   debug - set close timeout for client 217474157959916242
   warn  - client not handshaken client should reconnect
   info  - transport end

在客户端(浏览器)日志中,它会产生一个奇怪的错误:

Uncaught TypeError: Property 'open' of object #<c> is not a function
handshake.c.sessionidsocket.io.js:2
d.ready

RedisStore不会发生客户端错误,并且只有一个工作程序不会发生任何错误。我有充分的证据表明wrong number of arguments for 'hset'错误在socket.io的RedisStore代码中,因为我的代码中根本没有使用任何hset,而且MemoryStore也不会发生这种情况... < / p>

您认为它发生了什么?这值得向socket.io人报告吗?

1 个答案:

答案 0 :(得分:1)

我有类似的问题......虽然我在客户端没有任何错误,特别是在Android设备上 - 包括webview和本地浏览器。在我的情况下,我在传输的数据中使用UTF-8编码。我发现的是当我发出任何西里尔文本/数据的那一刻,消息被正确发送,然而,在此之后,传输被丢弃:

   debug - set close timeout for client 8983972932106614064
   debug - discarding transport
   debug - cleared close timeout for client 8983972932106614064
   debug - xhr-polling received data packet �88�5:::...

我认为这很可能是REDIS商店的问题。

顺便说一句,也许如果你注意到xhr-polling收到的数据包,redis商店(我相信)会发送另一个名为“ready”的请求......同样在这里......我在阻塞之后有两个请求同样的问题......