app = App()
app.ws('/ws', {
'message': ws_message
})
app.listen(3000, lambda config: print('Listening on port %d' % config.port))
app.run()
3. Start the program.
4. Connect to the server with a WebSocket client.
5. Send "Hello." to server.
6. Notice no error.
7. Send "Close me." to the server.
8. See error and program terminates.
Listening on port 3000
Segmentation fault: 11
**Expected behavior**
For the one connection to close without error and the server keep running to handle and listen for other connections.
**Desktop (please complete the following information):**
- OS: macOS
- Version: 12.6.1
- Architecture: Apple Silicon
Describe the bug Closing a WebSocket in the message handler causes a segmentation fault and the program terminates.
To Reproduce
def ws_message(ws, message, opcode): try: if message == 'Close me.': ws.close() except: print('error')
app = App() app.ws('/ws', { 'message': ws_message }) app.listen(3000, lambda config: print('Listening on port %d' % config.port)) app.run()
Listening on port 3000 Segmentation fault: 11