[pjsip] Error in pjsip_tpmgr_receive_packet with SIP over TCP using keep-alive

Helmut Wolf HelmutWolf1 at gmx.de
Tue Feb 12 14:08:55 EST 2008

Hi Benny,

I am using stateful proxy which transmits SIP over TCP. When TCP connection is established and for a time of min. 3 min no packets
are transmitted then the proxy receives an incoming packet on TCP socket but does not report it to pjsip endpoint. 

The problem is with TCP keep-alive packets (2 Bytes). This is transmitted every 90s. In sip_transport.c ->
pjsip_tpmgr_receive_packet() the packet will be reported to pjsip_find_msg() which normally returns a complete SIP msg. When this
function returns PJ_SUCCESS the SIP msg is reported to endpoint. But on an keep-alive packet the functions returns 171024 (on Win
XP, not sure, if platform dependent pjsip status code). The remaining length of the packet is 2. On next incoming keep-alive
pjsip_find_msg() returns 171050. The remaining length of the packet is now 4. And so on. If more than 3 keep-alive packets are
included in buffer and then a SIP msg is received, pjsip_find_msg() returns 171050. So a SIP msg exists in buffer but will not be
reported to the endpoint. 

This happens until the buffer is PJSIP_MAX_PKT_LEN (In my configuration 3000). Then the buffer will be cleared.

Could you please solve the problem? Maybe you can delete the keep-alive packet in buffer (in pjsip_tpmgr_receive_packet or

Best regards,

More information about the pjsip mailing list