[pjsip] Error in pjsip_tpmgr_receive_packet with SIP over TCPusing keep-alive
HelmutWolf1 at gmx.de
Fri Feb 15 05:36:14 EST 2008
That's no problem. I see how many support requests are sended to you...
The configuration is pjsip to pjsip so keep-alive packet contains CRLF. It seems the problem is in pjsip_find_msg(). At the
beginning (Line 772 in sip_parser.c):
/* Find the end of header area by finding an empty line. */
pos = pj_ansi_strstr(buf, "\n\r\n");
If one keep-alive exist there is no problem ("\n\r\n" is found at the end of SIP msg, not in keep-alive "\r\n"). But when more than
one keep-alive exist than the problem occurs ("\n\r\n" is found in keep-alive "\r\n\r\n..."). Herewith no SIP header can be found
and PJSIP_EMISSINGHDR is returned.
If I correct understand the buffer does always begin with keep-alive or a SIP msg. If the msg is incomplete the first positions of
the buffer does not change. On next incoming packet it will be attached. Isn't it a solution to remove CRLF if found at the first
position in the buffer?
Von: pjsip-bounces at lists.pjsip.org [mailto:pjsip-bounces at lists.pjsip.org] Im Auftrag von Benny Prijono
Gesendet: Donnerstag, 14. Februar 2008 18:20
An: pjsip list
Betreff: Re: [pjsip] Error in pjsip_tpmgr_receive_packet with SIP over TCPusing keep-alive
Sorry for the delay in getting back to you (and I still have dozen of
unanswered mails on this list, so please everyone be patient ;-) ).
Do you know what the content of the keep alive packets are? If it is
CRLF, then it should be okay (theoretically!), as when the real SIP
message arrives, these CRLF bytes will be ignored by the parser.
It's not so easy to drop bytes with TCP, as TCP is stream oriented
transport and data may come in small chunks. But maybe we can do
something about it, such as to drop CRLF bytes outside SIP message,
but before I do this I'd like to hear what the other endpoints are
sending in the keep-alive packets.
On 2/12/08, Helmut Wolf <HelmutWolf1 at gmx.de> wrote:
> 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
> 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,
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip at lists.pjsip.org
More information about the pjsip