wave icon indicating copy to clipboard operation
wave copied to clipboard

WebSockets: all client related processes are not properly destroyed in some cases

Open gbour opened this issue 8 years ago • 0 comments

when a client close its websocket connection without proper MQTT DISCONNECT, or when MQTT connection timesout:

  • mqtt_ranch_protocol process is not destroyed
  • mqtt_session and wave_websocket processes are destroyed after MQTT timeout (*1.5) only

Explanation:

  • when a client connects with WebSocket transport, 4 processes are created to handle client connection
    • wave_websocket_handler (a ranch listener) to receipt ws packets
    • mqtt_session is the MQTT FSM
    • mqtt_ranch_protocol is the generic low-level mqtt packets reader/writer
    • wave_websocket emulates a gen_tcp like socket by linking mqtt_ranch_protocol with wave_websocket_handler

when client disconnects properly (sending MQTT DISCONNECT PACKET), all 4 processes are properly destroyed (in order mqtt_session -> wave_websocket -> wave_websocket_handler & mqtt_ranch_protocol). But if client just close socket or let's mqtt session timeout, this is not done properly

gbour avatar Jul 13 '16 10:07 gbour