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