Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example-Server crashes when client leaves page #28

Open
software2000 opened this issue Sep 25, 2017 · 5 comments
Open

Example-Server crashes when client leaves page #28

software2000 opened this issue Sep 25, 2017 · 5 comments

Comments

@software2000
Copy link

Hey everyone,

everytime a client leaves the example webpage, app.js crashes.

console output:

`
Listening on port 9002
Got a client
Lost a client
/Users/user/Desktop/ios-minicap-master/example/node_modules/ws/lib/WebSocket.js:219
else throw new Error('not opened');
^

Error: not opened
at WebSocket.send (/Users/user/Desktop/ios-minicap-master/example/node_modules/ws/lib/WebSocket.js:219:16)
at Parser.onFrameAvailable (/Users/user/Desktop/ios-minicap-master/example/app.js:43:8)
at Parser.parse (/Users/user/Desktop/ios-minicap-master/example/node_modules/minicap/lib/parser.js:33:34)
at Socket.tryParse (/Users/user/Desktop/ios-minicap-master/example/app.js:56:14)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:432:10)
at emitReadable (_stream_readable.js:426:7)
at readableAddChunk (_stream_readable.js:187:13)
at Socket.Readable.push (_stream_readable.js:134:10)`

@sorccu
Copy link
Member

sorccu commented Sep 25, 2017

Haven't seen that before, but really, it's just a minimal example. You're supposed to make your own.

@sorccu
Copy link
Member

sorccu commented Sep 25, 2017

You should check ws.readyState (or use some other flag variable, or tear down instantly) in the onFrameAvailable callback.

@vbanthia-zz
Copy link
Member

vbanthia-zz commented Sep 25, 2017

It does crashes. Quick workaorund will be to use android-minicap example with some changes such as port number etc, https://github.com/openstf/minicap/tree/master/example

@software2000
Copy link
Author

software2000 commented Sep 27, 2017

Solution: Just add stream.destroy() to ws.on('close').

ws.on('close', () => {
console.info('Lost a client')
stream.end()
stream.destroy();
})

@software2000
Copy link
Author

#29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants