# Event routes

The 3 following routes are called when a socket is closed.

The corresponding $conid , $Ri , $Rp , $si , $sp and $proto variable will be available in the event routes.

Whether these routes are always called, never, or on a per socket basis is controlled by the closed_event parameter.

Note that the event routes can be executed by TCP main process, which manages the TCP connections but does not hande the SIP traffic over them. It is very important not do do any time consuming operations inside the event routes. Also, many resources might not be available in the TCP main process (e.g., database connections), consider using async module with async_task_data(...) or async_task_group_data() functions for delegating task execution to async workers.

## `tcp:closed`

Called for each "normal" TCP socket closure by the other side (FIN,ACK).

## `tcp:timeout`

Called for connection timeouts (unanswered keepalives).

## `tcp:reset`

Called if the connection is reset by peer (RST).

## `Example`

    ...
    event_route[tcp:closed] {
    	xlog("L_INFO", "$proto connection closed ($conid)\n");
    }

    event_route[tcp:timeout] {
    	xlog("L_INFO", "$proto connection timed out ($conid)\n");
    }

    event_route[tcp:reset] {
    	xlog("L_INFO", "$proto connection reset by peer ($conid)\n");
    }
    ...