Search code examples
sipmanagedlync

Second Lync application built on Managed SIP Application API is not receiving SIP messages


We have the same application built on the Managed SIP Application API that we wish to run twice on the same Front End server. They're using the same name, the same MSPL script and the same code except their configuration (.config) is slightly different.

What happens is the first instance we start works fine and is receiving SIP messages, but as soon as the second instance is started the first instance is no longer receiving any SIP messages and now only the second instance is receiving SIP messages. We would like for both of our instances to handle all the SIP messages which we've been unsuccessful in so far.

The MSPL script we're using to dispatch the SIP messages is:

<?xml version="1.0"?>
<r:applicationManifest
 r:appUri="http://example.com/ProgramName"
 xmlns:r="http://schemas.microsoft.com/lcs/2006/05">

  <!-- Handle incoming requests to Lync server -->
  <r:requestFilter methodNames="ALL"
                   strictRoute="true"
                   registrarGenerated="true"
                   domainSupported="true"/>

  <!-- Handle outgoing requests to Lync server-->
  <r:responseFilter reasonCodes="ALL"/>

  <r:splScript>
    <![CDATA[

if (sipRequest)
{
  //Ignoring benotify events.
  if(sipRequest.Method =="BENOTIFY")
  {
    return;
  }

  Dispatch("OnRequest");
}
else
{
  Dispatch("OnResponse");
}

]]>
  </r:splScript>
</r:applicationManifest>

which are handled by the following OnRequest and OnResponse messages:

public void OnRequest(object sender, RequestReceivedEventArgs evt)
{
  // Do some stuff with evt.Message

  evt.ServerTransaction.EnableForking = false;
  evt.ServerTransaction.CreateBranch().SendRequest(message.Message as Request);
}

public void OnResponse(object sender, ResponseReceivedEventArgs evt)
{
  // Do some stuff with evt.Message

  evt.ClientTransaction.ServerTransaction.SendResponse(message.Message as Response);
}

Here's how these programs are registered as server applications (output from Get-CsServerApplication):

Identity   : Service:Registrar:FQDN/ExampleProgramName
Priority   : 12
Uri        : http://example.com/ProgramName
Name       : ExampleProgramName
Enabled    : True
Critical   : False
ScriptName : 
Script     : 

Identity   : Service:Registrar:FQDN/ExampleProgramName
Priority   : 13
Uri        : http://example.com/ProgramName
Name       : ExampleProgramName
Enabled    : True
Critical   : False
ScriptName : 
Script     : 

We've also tried registering the same application under different names. For example, we renamed one of the two instances to ExampleProgramName2 in the MSPL script as well as in New-CsServerApplication which did not work either.

In particular, we are unsure about the requestFilter in the MSPL script and the particular SendResponse/SendRequest method calls as well as the EnableForking property.


Solution

  • Register the server application with different names:

    New-CsServerApplication -Identity FQDN/ExampleProgramName1 -Uri http://example.com/ProgramName1 -Critical $False
    New-CsServerApplication -Identity FQDN/ExampleProgramName2 -Uri http://example.com/ProgramName2 -Critical $False
    

    As well as give each program their unique name in MSPL matching the value given in the Uri parameter of New-CsServerApplication:

    <r:applicationManifest
      r:appUri="http://example.com/ProgramName1"
    
    <r:applicationManifest
      r:appUri="http://example.com/ProgramName2"
    

    This should be enough.