Re: [cipango-users] forceClientRport problem with routeOutgoingRequests set as false

83 views
Skip to first unread message

Nicolas Trangosi

unread,
Oct 5, 2012, 4:07:17 AM10/5/12
to cipang...@googlegroups.com
Hi Mikko,
The forceClientRport parameter is checked when a request is received, if set to
true it ensures that the response will be sent to port on which request has been
received.

In your case, I think that you want cipango to add the rport parameter to
request sent by Cipango. For this, you should apply the joined patch on Cipango
source code.If it fit your needs, please open a new jira issue on
http://jira.cipango.org in order this patch to be included in Cipango.

Regards,
Nicolas


Le 05/10/2012 08:37, Mikko Kaistinen a �crit :
> Hi,
>
> My servlet is acting as proxy server(acting both client and server). Proxy
> tries to send subscribe message to server which is behind firewall to get the
> presence data.
> What I have understand so far that I need to set forceClientRport as true so
> that answer from server gets back to my proxy while there is firewall between
> my proxy and server.
>
> I have also set routeOutgoingRequests as false since other wise subscribe
> request is caught by my own servlet and those won't get delivered to server.
> While I'm using both of these options rport parameter is not present in
> outgoing request and obviously my proxy won't get any answer from server.
>
> Is this correct behaviour or have I misunderstand something?
> --
> You received this message because you are subscribed to the Google Groups
> "cipango-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cipango-users/-/919dRNO9I8EJ.
> To post to this group, send email to cipang...@googlegroups.com.
> To unsubscribe from this group, send email to
> cipango-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cipango-users?hl=en.

addLocalRport.patch

Mikko Kaistinen

unread,
Oct 5, 2012, 4:18:20 AM10/5/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Thanks for quick reply!

I got newest version(revision 839) from SVN trunk which has this patch applied.

While I got rport set as true: <Set name="forceClientRport">true</Set> 

And if I set <Set name="routeOutgoingRequests">true</Set> rport will get added to request which I'm sending, but request is routed to my proxy servlet not to the server. 
So I have to add <Set name="routeOutgoingRequests">false</Set> in order to send the request to actual server, then rport parameter won't get added to VIA header for some reason.

In short: rport parameter won't exists in VIA header while routeOutgoingRequests is set as false

Mikko


On Friday, 5 October 2012 11:07:23 UTC+3, Nicolas Trangosi wrote:
Hi Mikko,
The forceClientRport parameter is checked when a request is received, if set to
true it ensures that the response will be sent to port on which request has been
received.

In your case, I think that you want cipango to add the rport parameter to
request sent by Cipango. For this, you should apply the joined patch on Cipango
source code.If it fit your needs, please open a new jira issue on
http://jira.cipango.org in order this patch to be included in Cipango.

Regards,
Nicolas


Le 05/10/2012 08:37, Mikko Kaistinen a �crit :
> Hi,
>
> My servlet is acting as proxy server(acting both client and server). Proxy
> tries to send subscribe message to server which is behind firewall to get the
> presence data.
> What I have understand so far that I need to set forceClientRport as true so
> that answer from server gets back to my proxy while there is firewall between
> my proxy and server.
>
> I have also set routeOutgoingRequests as false since other wise subscribe
> request is caught by my own servlet and those won't get delivered to server.
> While I'm using both of these options rport parameter is not present in
> outgoing request and obviously my proxy won't get any answer from server.
>
> Is this correct behaviour or have I misunderstand something?
> --
> You received this message because you are subscribed to the Google Groups
> "cipango-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cipango-users/-/919dRNO9I8EJ.
> To post to this group, send email to cipang...@googlegroups.com.
> To unsubscribe from this group, send email to
> cipango-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cipango-users?hl=en.


Index: src/main/config/etc/cipango.xml
===================================================================
--- src/main/config/etc/cipango.xml        (revision 822)
+++ src/main/config/etc/cipango.xml        (working copy)
@@ -70,6 +70,8 @@
          and no ";rport" is given in that Via (RFC 3581), force ";rport=..."
          in that Via header anyway so Cipango can route back replies correctly -->
     <Set name="forceClientRport">false</Set>
+    <!-- Add the rport parameter in Via header of sent request (RFC 3581) -->
+    <Set name="addLocalRport">true</Set>
   </Get>
 
   <!-- Set name="applicationRouter">
Index: src/main/java/org/cipango/server/ConnectorManager.java
===================================================================
--- src/main/java/org/cipango/server/ConnectorManager.java        (revision 835)
+++ src/main/java/org/cipango/server/ConnectorManager.java        (working copy)
@@ -73,6 +73,7 @@
     private int _largeMessageSize = MAX_MESSAGE_SIZE;
     
     private boolean _forceClientRport;
+    private boolean _addLocalRport = false;
         
     public void addConnector(SipConnector connector)
     {
@@ -741,5 +742,15 @@
                 _forceClientRport = forceClientRport;
         }
 
+        public boolean isAddLocalRport()
+        {
+                return _addLocalRport;
+        }
 
+        public void setAddLocalRport(boolean addLocalRport)
+        {
+                _addLocalRport = addLocalRport;
+        }
+
+
 }
Index: src/main/java/org/cipango/server/transaction/ClientTransaction.java
===================================================================
--- src/main/java/org/cipango/server/transaction/ClientTransaction.java        (revision 835)
+++ src/main/java/org/cipango/server/transaction/ClientTransaction.java        (working copy)
@@ -223,6 +223,9 @@
                 {
                         via.addParameter(ID.APP_SESSION_ID_PARAMETER, _request.appSession().getAppId());
                 }
+                
+                if (getServer().getConnectorManager().isAddLocalRport())
+                        via.setRport("");
         }
         
         public void start() throws IOException

Nicolas Trangosi

unread,
Oct 5, 2012, 5:08:33 AM10/5/12
to cipang...@googlegroups.com
The joined patch added a new parameter addLocalRport and has not been included in SVN.
This patch (addLocalRport.patch) is for outgoing requests while forceClientRport is for incoming requests.

Regards,
Nicolas

Mikko Kaistinen

unread,
Oct 5, 2012, 5:28:52 AM10/5/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
OK thanks, I try that.

Mikko

On Friday, 5 October 2012 11:07:23 UTC+3, Nicolas Trangosi wrote:
Hi Mikko,
The forceClientRport parameter is checked when a request is received, if set to
true it ensures that the response will be sent to port on which request has been
received.

In your case, I think that you want cipango to add the rport parameter to
request sent by Cipango. For this, you should apply the joined patch on Cipango
source code.If it fit your needs, please open a new jira issue on
http://jira.cipango.org in order this patch to be included in Cipango.

Regards,
Nicolas


Le 05/10/2012 08:37, Mikko Kaistinen a �crit :
> Hi,
>
> My servlet is acting as proxy server(acting both client and server). Proxy
> tries to send subscribe message to server which is behind firewall to get the
> presence data.
> What I have understand so far that I need to set forceClientRport as true so
> that answer from server gets back to my proxy while there is firewall between
> my proxy and server.
>
> I have also set routeOutgoingRequests as false since other wise subscribe
> request is caught by my own servlet and those won't get delivered to server.
> While I'm using both of these options rport parameter is not present in
> outgoing request and obviously my proxy won't get any answer from server.
>
> Is this correct behaviour or have I misunderstand something?
> --
> You received this message because you are subscribed to the Google Groups
> "cipango-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cipango-users/-/919dRNO9I8EJ.
> To post to this group, send email to cipang...@googlegroups.com.
> To unsubscribe from this group, send email to
> cipango-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cipango-users?hl=en.
Message has been deleted

Mikko Kaistinen

unread,
Oct 19, 2012, 5:02:30 AM10/19/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Hi,

is there any possibility to update port value of Contact header on authentication message which is send to server.
Contact: <sip:<IP>:<port value>;transport=tls;app-session-id=<ID>>

I need to assign the port value to Contact header that server gives to proxy servlet via the challenge message sent by server to proxy.

PROXY                 SERVER
Subscribe       ->
                     <-    Challenge (401)
Authentication ->
                     <-    OK (200) / false (403)

Mikko


On Friday, 5 October 2012 11:07:23 UTC+3, Nicolas Trangosi wrote:
Hi Mikko,
The forceClientRport parameter is checked when a request is received, if set to
true it ensures that the response will be sent to port on which request has been
received.

In your case, I think that you want cipango to add the rport parameter to
request sent by Cipango. For this, you should apply the joined patch on Cipango
source code.If it fit your needs, please open a new jira issue on
http://jira.cipango.org in order this patch to be included in Cipango.

Regards,
Nicolas


Le 05/10/2012 08:37, Mikko Kaistinen a �crit :
> Hi,
>
> My servlet is acting as proxy server(acting both client and server). Proxy
> tries to send subscribe message to server which is behind firewall to get the
> presence data.
> What I have understand so far that I need to set forceClientRport as true so
> that answer from server gets back to my proxy while there is firewall between
> my proxy and server.
>
> I have also set routeOutgoingRequests as false since other wise subscribe
> request is caught by my own servlet and those won't get delivered to server.
> While I'm using both of these options rport parameter is not present in
> outgoing request and obviously my proxy won't get any answer from server.
>
> Is this correct behaviour or have I misunderstand something?
> --
> You received this message because you are subscribed to the Google Groups
> "cipango-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cipango-users/-/919dRNO9I8EJ.
> To post to this group, send email to cipang...@googlegroups.com.
> To unsubscribe from this group, send email to
> cipango-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cipango-users?hl=en.

Nicolas Trangosi

unread,
Oct 19, 2012, 5:15:19 AM10/19/12
to cipang...@googlegroups.com
Miko,
This depends of the method. If it is REGISTER, then the servlet application can modified the contact, if it is an INVITE or a SUBSCRIBE, then the contact is managed by the container (cipango) and port cannot be modified by the application.

Regards,
Nicolas
To view this discussion on the web visit https://groups.google.com/d/msg/cipango-users/-/fAYTmA4ErXgJ.

Mikko Kaistinen

unread,
Oct 19, 2012, 5:30:00 AM10/19/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
It's SUBSCRIBE as it marked on message sequence diagram.

Is there any other possibility solve this problem than use javax.sip.* libraries instead servlet?

BR,
Mikko

Nicolas Trangosi

unread,
Oct 19, 2012, 11:45:19 AM10/19/12
to cipang...@googlegroups.com
Miko,
You could use the join patch.
If there is the attribute "org.cipango.contact.port" in the request and this attribute is an integer, then this value is used.

As this patch is specific, it will not be included in trunk.

Regards,
Nicolas
To view this discussion on the web visit https://groups.google.com/d/msg/cipango-users/-/t6k2VjM4Mu8J.
customizePort.patch

Mikko Kaistinen

unread,
Oct 22, 2012, 2:17:07 AM10/22/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Hi Nicolas,

does that patch need some configuration changes in cipango.xml or some other tricks?
I applied the patch, compiled and tested. Rport value wasn't copied to Contact header. 
Actually nothing seemed to change.

Long story short, 
I need Via header rport value of 401 Unauthorized message to be applied to Contact header of second subscribe message with authentication header, which sent to server.

This "feature" seems to be pretty obscurely documented in RFCs, but server side is not in my control.

Mikko


On Friday, 19 October 2012 18:45:32 UTC+3, Nicolas Trangosi wrote:
Miko,

Mikko Kaistinen

unread,
Oct 22, 2012, 6:49:04 AM10/22/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
I solved the problem, thanks for the patch!

BR,
Mikko

Mikko Kaistinen

unread,
Nov 19, 2012, 9:15:12 AM11/19/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Hi, 

while I'm sending subscription refresh message to server. I access current session by 
SipServletRequest sipServletRequest = SipBrokerServlet.sipSession.createRequest("SUBSCRIBE");

sipServletRequest.setRequestURI(toURI);
sipServletRequest.addAuthHeader(SipBrokerServlet.sipResponse, SipBrokerServlet.authInfo);
sipServletRequest.setHeader("Expires", sipConfiguration.getExpireTimeout().toString());
sipServletRequest.setHeader("Event", "presence");
sipServletRequest.setHeader("Content-Type", "application/pidf+xml");

is there any method to change the From -header field? With sipServletRequest.setRequestURI(toURI); I'm able to change To -header field, but I haven't found proper way to change To header field.
Currently From value is server's address so To and From header fields are same, but I need to change proxy's address to From field. How can I fix this?

Use case: 

PROXY                 SERVER
Subscribe       ->
                     <-    Challenge (401)
Authentication ->
                     <-    OK (200)
(SUBSCRIPTION interval)

Subscription refresh(with addAuthHeader) -> 
                     <-    OK (200)
                     <-    NOTIFY
OK (200)        -> 

Nicolas Trangosi

unread,
Nov 19, 2012, 10:13:15 AM11/19/12
to cipang...@googlegroups.com
Hi Mikko,
The From and To headers are system headers and so are not modifiable after message creation.

You need to create a new SipSession using the SipFactory:

SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
SipServletRequest invite = sipFactory .createRequest(request.getApplicationSession(),
                    "SUBSCRIBE", "sip:al...@cipango.org", "sip:b...@cipango.org");

Regards,
Nicolas
--
You received this message because you are subscribed to the Google Groups "cipango-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cipango-users/-/wIu8-s-tgksJ.

Mikko Kaistinen

unread,
Nov 19, 2012, 3:06:04 PM11/19/12
to cipango-users
Hi, thanks for quick reply.

I already tried that, but the problem with new session is that it
won't update Cseq header value.
Is it suppose to do that?
Like first subscribe message Cseq 1
next message Cseq 2
and so forth...

BR,
Mikko


On 19 marras, 17:20, Nicolas Trangosi <nicolas.trang...@nexcom.fr>
wrote:
> Hi Mikko,
> The From and To headers are system headers and so are not modifiable after
> message creation.
>
> You need to create a new SipSession using the SipFactory:
>
> SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
> SipServletRequest invite = sipFactory
> .createRequest(request.getApplicationSession(),
>                      "SUBSCRIBE", "sip:al...@cipango.org", "sip:b...@cipango.org");
>
> Regards,
> Nicolas
>
> Le 19/11/2012 15:15, Mikko Kaistinen a �crit :
>
>
>
>
>
>
>

Nicolas Trangosi

unread,
Nov 20, 2012, 2:55:18 AM11/20/12
to cipang...@googlegroups.com
Mikko,
You should create first a new request session with right from and to using the
SIP factory. Then on 401, you could reuse the session of the challenge response
to create a request. The from and to header are set with right value and CSeq is
incremented.

Kind regards,
Nicolas

Le 19/11/2012 21:06, Mikko Kaistinen a �crit :
>> Le 19/11/2012 15:15, Mikko Kaistinen a �crit :
>>
>>
>>
>>
>>
>>
>>

Mikko Kaistinen

unread,
Nov 20, 2012, 5:41:08 AM11/20/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Yeah, that was my original solution.
Problem was that when I send next subscription refresh message Cseq value for SUBSCRIBE message drops back to 1 instead of increasing.

Server specs define that Subscription Cseq value keeps increasing with each new subscription refresh message.

Use case:
PROXY                 SERVER                              Cseq
Subscribe       ->                                               1
                     <-    Challenge (401)                     1
Authentication ->                                               2
                     <-    OK (200)                               2
(SUBSCRIPTION interval)

Subscription refresh(with addAuthHeader) ->        1 (Should be 3)
                     <-    OK (200)                               1 (Should be 3)
                     <-    NOTIFY                                something else
OK (200)        ->                                                something else


Mikko

Nicolas Trangosi

unread,
Nov 20, 2012, 5:53:57 AM11/20/12
to Mikko Kaistinen, cipang...@googlegroups.com
Mikko,
I could not see any reason for CSeq drop back to one.
Could you send me a wireshark trace or Cipango message log ?

Kind regards,
Nicolas

Mikko Kaistinen

unread,
Nov 20, 2012, 8:05:29 AM11/20/12
to cipang...@googlegroups.com, Mikko Kaistinen, nicolas....@nexcom.fr
Unfortunately, I can't. It contains confidental information and it also encrypted via TLS and I don't have possibility test without encryption. :/

but in first place I create first Subscribe message in 
public void servletInitialized(SipServletContextEvent sipServletContextEvent)
and use sipServletContextEvent to create sipFactory object

then I create sipServletRequest by sipServletRequest = sipFactory.createRequest(sipApplicationSession, sipConfiguration.getRequestForm(), fromURI, toURI);
and send it to server.

protected void doErrorResponse(SipServletResponse response) method uses 
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
to create authentication header for response message to server which is created by using SipServletRequest challengeRequest = response.getSession().createRequest(response.getRequest().getMethod());

After that proxy gets 200 OK message back.

Before session expires proxy sends:
SipServletRequest sipServletRequest = sipFactory.createRequest(sipApplicationSession, sipConfiguration.getRequestForm(), fromURI, toURI);
to server and gets 200 OK back, but Cseq number rolled back to 1.


Mikko


On Tuesday, 20 November 2012 12:54:07 UTC+2, Nicolas Trangosi wrote:
Mikko,

Nicolas Trangosi

unread,
Nov 20, 2012, 8:45:35 AM11/20/12
to cipang...@googlegroups.com
Mikko,
You should reuse the same session for re-subscription to create the request: sipSession.createRequest("SUBSCRIBE")
--
You received this message because you are subscribed to the Google Groups "cipango-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cipango-users/-/LIMG2g4r6FYJ.

Mikko Kaistinen

unread,
Nov 21, 2012, 8:38:07 AM11/21/12
to cipang...@googlegroups.com, nicolas....@nexcom.fr
Hi,

put back sipSession.createRequest("SUBSCRIBE");
and created the subscription refresh sipServletRequest.

But I need to add authorization header also to the new sipServletRequest, 
like this way

SipServletRequest sipServletRequest = sipSession.createRequest("SUBSCRIBE");
sipServletRequest.addAuthHeader(sipResponse, authInfo);
sipServletRequest.setHeader("Expires", sipConfiguration.getExpireTimeout());
sipServletRequest.setHeader("Event", "presence");
sipServletRequest.setHeader("Content-Type", "application/pidf+xml");
sipServletRequest.send();

problem is that sipServletRequest.addAuthHeader(sipResponse, authInfo) is designed to produce authorization header to challenge request which comes from server, 
but in subscription refresh case, proxy have to send message to server without challenge request. Is authorization header possible to add some other way?

Use case:
Subscription refresh(with authorization header) -> 
                     <-    OK (200)
                     <-    NOTIFY
OK (200)        -> 


BR,
Mikko


On Tuesday, 20 November 2012 15:45:36 UTC+2, Nicolas Trangosi wrote:
Mikko,

Nicolas Trangosi

unread,
Nov 21, 2012, 9:37:31 AM11/21/12
to cipang...@googlegroups.com
Mikko,
The SIP servlet API is limited, you should manage authentication manualy like it is done in Registration class of Cipango client (Code source available at http://fisheye.cipango.org/browse/cipango/trunk/cipango-client/src/main/java/org/cipango/client/Registration.java?hb=true).

Regards,
Nicolas
--
You received this message because you are subscribed to the Google Groups "cipango-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cipango-users/-/feOsHKms0UoJ.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages