1
我写了一个简单的Node.js WebSocket chat server。要运行服务器,我使用foreman start
,其中Procfile
仅包含行:chat: npm start
。SocketRocket崩溃Node.js WebSocket
我还写了一个iPhone应用程序,它使用SocketRocket来连接上述服务器。在applicationDidEnterBackground:
,我打电话close
在webSocket
。并且,在applicationWillEnterForeground:
中,我重新创建了webSocket
并致电open
。
当进入背景或前景,iPhone的应用程序似乎与错误导致服务器崩溃:
chat.1 | events.js:74
chat.1 | throw TypeError('Uncaught, unspecified "error" event.');
chat.1 | ^
chat.1 | TypeError: Uncaught, unspecified "error" event.
chat.1 | at TypeError (<anonymous>)
chat.1 | at WebSocket.EventEmitter.emit (events.js:74:15)
chat.1 | at Receiver.self._receiver.onerror (~/Projects/Chat/node_modules/ws/lib/WebSocket.js:719:10)
chat.1 | at Receiver.error (~/Projects/Chat/node_modules/ws/lib/Receiver.js:301:8)
chat.1 | at Receiver.opcodes.8.finish (~/Projects/Chat/node_modules/ws/lib/Receiver.js:497:14)
chat.1 | at Receiver.<anonymous> (~/Projects/Chat/node_modules/ws/lib/Receiver.js:478:33)
chat.1 | at Receiver.add (~/Projects/Chat/node_modules/ws/lib/Receiver.js:93:24)
chat.1 | at Socket.firstHandler (~/Projects/Chat/node_modules/ws/lib/WebSocket.js:678:22)
chat.1 | at Socket.EventEmitter.emit (events.js:95:17)
chat.1 | at Socket.<anonymous> (_stream_readable.js:746:14)
chat.1 | npm ERR! weird error 8
chat.1 | npm ERR! not ok code 0
chat.1 | exited with code 1
system | sending SIGTERM to all processes
这究竟是为什么?而且,我该如何解决它?
你知道吗? – mauricioSanchez