Sip Servlets - Control Not Passed to Next Servlet in Chain - jboss7.x

I am working with Mobicents Sip Servlets 3.0.0-SNAPSHOT. I have two servlets configured in the DAR; one to check to see if a third party registration is being attempted, and a second to perform the actual registration. I am finding that when the REGISTER arrives, it is passed to the first servlet (BlockerApp); but when that servlet completes and proxies to the next, that the second servlet (RegApp) is not called. Instead, the first servlet is called again, with the routing directive set to NEW.
Any ideas? Am I missing something?
DAR configuration:
REGISTER=("RegApp","DAR\:From","ORIGINATING","","NO_ROUTE","1"),("BlockerApp","DAR\:From","ORIGINATING","","NO_ROUTE","0")
First Servlet:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.sip.Proxy;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipURI;
import org.apache.log4j.Logger;
#javax.servlet.sip.annotation.SipServlet(name = "Blocker", loadOnStartup = 1)
public class Blocker extends SipServlet {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Blocker.class);
private static final String LOOP_CHECK_HEADER = "X-looping";
#Override
protected void doRegister(SipServletRequest req) throws ServletException,
IOException {
logger.info("######################################################");
logger.info("Blocker");
logger.info("region:" + req.getRegion());
logger.info("routing directive:" + req.getRoutingDirective());
logger.info("subscriber uri:" + req.getSubscriberURI());
logger.info("popped route:" + req.getPoppedRoute());
logger.info("######################################################");
if (req.getHeader(LOOP_CHECK_HEADER) != null
&& !req.getHeader(LOOP_CHECK_HEADER).isEmpty()) {
SipServletResponse resp = req
.createResponse(SipServletResponse.SC_FORBIDDEN);
resp.send();
return;
}
req.addHeader(LOOP_CHECK_HEADER, "1");
String toUser = null;
if (req.getTo().getURI().isSipURI()) {
toUser = ((SipURI) req.getTo().getURI()).getUser();
}
String fromUser = null;
if (req.getFrom().getURI().isSipURI()) {
fromUser = ((SipURI) req.getFrom().getURI()).getUser();
}
if (toUser != null && fromUser != null && toUser.equals(fromUser)) {
Proxy proxy = req.getProxy();
proxy.proxyTo(req.getRequestURI());
} else {
SipServletResponse rsp = req.createResponse(
SipServletResponse.SC_DECLINE,
"No third party registrations accepted");
rsp.send();
}
}
}
Second Servlet:
import java.io.IOException;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.sip.Address;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipURI;
import org.apache.log4j.Logger;
import com.mcleodnet.registrar.business.ContactInformationService;
import com.mcleodnet.registrar.data.ContactUpdate;
#javax.servlet.sip.annotation.SipServlet(name = "Registrar", loadOnStartup = 1)
public class Registrar extends SipServlet {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Registrar.class);
#EJB(lookup = "java:global/Registrar/RegistrarDatabase/ContactInformationServiceImpl!com.mcleodnet.registrar.business.ContactInformationServiceLocal")
private ContactInformationService cis;
#Resource
SipFactory sipFactory;
#Override
protected void doRegister(SipServletRequest req) throws ServletException,
IOException {
logger.info("######################################################");
logger.info("Registrar");
logger.info("region:" + req.getRegion());
logger.info("routing directive:" + req.getRoutingDirective());
logger.info("subscriber uri:" + req.getSubscriberURI());
logger.info("popped route:" + req.getPoppedRoute());
logger.info("######################################################");
SipServletResponse rsp = req.createResponse(SipServletResponse.SC_OK,
"OK");
Address contactHeader = req.getAddressHeader("contact");
String contactUri = contactHeader.getURI().toString();
String username = null;
if (req.getTo().getURI().isSipURI()) {
username = ((SipURI) req.getTo().getURI()).getUser();
}
int expires = req.getExpires();
if (expires == -1) {
expires = contactHeader.getExpires();
}
if (expires == 0) {
cis.deleteContactInformation(username);
} else {
cis.updateContactInformation(username, new ContactUpdate(
contactUri, expires));
}
rsp.send();
}
}
Log:
11:56:40,296 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) <message
from="192.168.100.125:5090"
to="0.0.0.0:5080"
time="1399921000293"
isSender="false"
transactionId="z9hg4bk-d8754z-7178ee0abc532a51-1---d8754z-"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 70
Contact: <sip:110#192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110#192.168.100.136:5080>
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5 stamp 71236
Content-Length: 0
]]>
</message>
11:56:40,297 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) ######################################################
11:56:40,298 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) Blocker
11:56:40,298 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) region:ORIGINATING
11:56:40,298 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) routing directive:NEW
11:56:40,299 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) subscriber uri:sip:110#192.168.100.136:5080
11:56:40,299 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) popped route:null
11:56:40,299 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) ######################################################
11:56:40,302 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) <message
from="192.168.100.136:5080"
to="0.0.0.0:5080"
time="1399921000301"
isSender="false"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 69
Contact: <sip:110#192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110#192.168.100.136:5080>
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5 stamp 71236
X-looping: 1
Content-Length: 0
]]>
</message>
11:56:40,303 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) ######################################################
11:56:40,303 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Blocker
11:56:40,303 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) region:ORIGINATING
11:56:40,304 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) routing directive:NEW
11:56:40,304 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) subscriber uri:sip:110#192.168.100.136:5080
11:56:40,304 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) popped route:null
11:56:40,304 INFO [com.mcleodnet.tpblockerapp.Blocker] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) ######################################################
11:56:40,305 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) <message
from="0.0.0.0:5080"
to="192.168.100.136:5080"
time="1399921000300"
isSender="true"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="REGISTER sip:192.168.100.136:5080 SIP/2.0"
>
<![CDATA[REGISTER sip:192.168.100.136:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
Max-Forwards: 69
Contact: <sip:110#192.168.100.125:5090;rinstance=664938eda63f586d;transport=udp>
To: "110" <sip:110#192.168.100.136:5080>
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY,MESSAGE,SUBSCRIBE,INFO
User-Agent: X-Lite release 4.5.5 stamp 71236
X-looping: 1
Content-Length: 0
]]>
</message>
11:56:40,307 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-5) <message
from="192.168.100.136:5080"
to="0.0.0.0:5080"
time="1399921000307"
isSender="false"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110#192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Content-Length: 0
]]>
</message>
11:56:40,305 INFO [org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher] (Mobicents-SIP-Servlets-UDPMessageChannelThread-3) Request event dispatched to BlockerApp
11:56:40,308 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) <message
from="0.0.0.0:5080"
to="192.168.100.136:5080"
time="1399921000306"
isSender="true"
transactionId="z9hg4bk6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110#192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.136:5080;branch=z9hG4bK6ef3edb8-3d39-4b3c-828d-5706b6bce40d_74a2f52c_8017367923679066
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Content-Length: 0
]]>
</message>
11:56:40,308 INFO [org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Request event dispatched to BlockerApp
11:56:40,310 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-5) <message
from="0.0.0.0:5080"
to="192.168.100.125:5090"
time="1399921000309"
isSender="true"
transactionId="z9hg4bk-d8754z-7178ee0abc532a51-1---d8754z-"
callId="NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE"
firstLine="SIP/2.0 403 Forbidden"
>
<![CDATA[SIP/2.0 403 Forbidden
To: "110" <sip:110#192.168.100.136:5080>;tag=27182159_74a2f52c_f3f49504-2264-4b83-bfe2-48103366fb36
Via: SIP/2.0/UDP 192.168.100.125:5090;branch=z9hG4bK-d8754z-7178ee0abc532a51-1---d8754z-
CSeq: 1 REGISTER
Call-ID: NjU5YTg5OGRhZjg5YzVjNWEzOWFhYTIyZmJiYjMwZmE
From: "110" <sip:110#192.168.100.136:5080>;tag=52ca933d
Content-Length: 0
]]>
</message>

I now understand why is was not working for me. SIP Servlet chaining using the DAR only works with methods which have dialogs usch as INVITE, SUBSCRIBE, NOTIFY, etc. I have tried using DAR with a multi-servlet application handling an INVITE, and it works as expected.

Application Routing for REGISTER is now fixed in the latest git HEAD

Related

NLog 5.0 - Filtering Microsoft.Extensions.Logging logs doesn't work

I've migrated an ASP.NET Core project from 3.1 to 6.0 and now I can't get rid of many Microsoft logs when using an Authentication middleware
For example, I always have those logs when I call my API endpoint having[Authorize(Roles = "admin")] annotation from an unauthorized client
2022-06-08 14:36:28.1023 INFO Microsoft.Extensions.Logging.LoggingExtensions.AuthenticationSchemeChallenged AuthenticationScheme: Bearer was challenged.
2022-06-08 14:40:58.7025 INFO Microsoft.Extensions.Logging.LoggingExtensions.AuthenticationSchemeChallenged AuthenticationScheme: Bearer was challenged.
2022-06-08 14:42:53.8049 INFO Microsoft.Extensions.Logging.LoggingExtensions.AuthenticationSchemeChallenged AuthenticationScheme: Bearer was challenged.
I also have those logs when calling another API using a Refit Client
2022-06-07 13:38:35.6434 INFO Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler+Log.RequestEnd Received HTTP response headers after 78.0306ms - 200
2022-06-07 13:38:35.6434 INFO Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler+Log.RequestPipelineEnd End processing HTTP request after 81.3323ms - 200
2022-06-07 13:38:35.6947 INFO Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler+Log.RequestPipelineStart Start processing HTTP request POST https://api.removed.com/endpoint
2022-06-07 13:38:35.6947 INFO Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler+Log.RequestStart Sending HTTP request POST https://api.removed.com/endpoint
2022-06-07 13:38:35.8336 INFO Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler+Log.RequestEnd Received HTTP response headers after 136.3691ms - 200
2022-06-07 13:38:35.8336 INFO Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler+Log.RequestPipelineEnd End processing HTTP request after 139.7244ms - 200
2022-06-07 13:38:35.8418 INFO Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler+Log.RequestStart Sending HTTP request POST https://api.removed.com/endpoint
2022-06-07 13:38:37.2229 INFO Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler+Log.RequestEnd Received HTTP response headers after 1379.9163ms - 200
2022-06-07 13:38:37.2229 INFO Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler+Log.RequestPipelineEnd End processing HTTP request after 2437.5144ms - 200
Program.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Web;
using System;
namespace CDL_CloudServerApi
{
public class Program
{
public static void Main(string[] args)
{
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
try
{
logger.Debug("Create Host");
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
//NLog: catch setup errors
logger.Error(ex, "Stopped program because of exception");
throw;
}
finally
{
LogManager.Shutdown();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseUrls("http://*:8282")
.UseStartup<Startup>()
.UseNLog();
});
}
}
nlog.config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off"
internalLogFile="c:\temp\nlog-internal.log">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<variable name="verbose" value="${longdate} ${uppercase:${level}} ${callsite:className=true:fileName=false:includeSourcePath=false:methodName=true:cleanNamesOfAnonymousDelegates=false:skipFrames=0} ${message}" />
<variable name="verbose_inline" value="${replace:inner=${verbose}:searchFor=\\r\\n|\\n:replaceWith=->:regex=true} ${exception:format=toString,Data:maxInnerExceptionLevel=10}"/>
<!-- 5GB max size per log-->
<targets>
<target name="logfile" xsi:type="File"
fileName="${basedir}/log/logfile.txt"
layout="${verbose_inline}"
archiveFileName="${basedir}/log/archives/log.{#}.txt"
archiveNumbering="Date"
archiveDateFormat="yyyy-MM-dd"
archiveEvery="Day"
archiveAboveSize="5000000000"
maxArchiveFiles="14"
maxArchiveDays="7"
concurrentWrites="true"
keepFileOpen="false" />
</targets>
<rules>
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" finalMinLevel="Warn" />
<logger name="System.Net.Http.*" finalMinLevel="Warn" />
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
</nlog>
You should include ${logger} in your layout, so you can see the logger-name that should be filtered away.
<variable name="verbose" value="${longdate} ${level:uppercase=true} ${logger} ${message}" />
<variable name="verbose_inline" value="${replace-newlines:replacement=->:${verbose}} ${exception:format=toString,Data}"/>
Alternative update to minLevel="Warn" for everything:
<logger name="*" minlevel="Warn" writeTo="logfile" />
Alternative specify RemoveLoggerFactoryFilter = false for NLogProviderOptions when calling UseNLog() as mentioned in NLog 5.0 - List of major changes. Then NLog will continue to follow Microsoft Logggng Filter-configuration.
Notice that you should be careful with ${callsite}, since it introduces a huge performance overhead.
Notice that ${replace-newlines} is faster than ${replace} with regex.

One way audio with WebRTC and Asterisk 15

I have two ways audio when calling from a WebRTC client connected to Asterisk to my mobile phone, but when I call from the mobile phone to the WebRTC client the call is established and there is only one way audio: from the WebRTC client to the mobile phone.
I'm using Asterisk 15.6.1 installed on a VPS with static IP, the WebRTC client is a browser softphone using the SIP.js library, and I have a local phone number from Localphone.
My "pjsip.conf" relevant settings are:
[localphone]
type=registration
transport=transport-udp
outbound_auth=localphone
client_uri = sip:12345678#localphone.com:5060
server_uri = sip:localphone.com:5060
auth_rejection_permanent=no
contact_user=12345678
[localphone]
type=auth
auth_type=userpass
username=12345678
password=mypassword
[localphone]
type=aor
max_contacts=100
contact=sip:12345678#localphone.com
[localphone]
type=endpoint
transport=transport-udp
context=localphone-inc
disallow = all
allow = ulaw
allow = alaw
rtcp_mux=yes
ice_support=yes
direct_media=no
from_user=12345678
from_domain=localphone.com
outbound_auth=localphone
aors=localphone
[localphone]
type = identify
endpoint = localphone
match = 140.153.72.56
; This is the WebRTC client
[1652]
type=aor
max_contacts=100
[auth1652]
type=auth
auth_type=userpass
username=1652
password=complicatedpassword
[1652]
type=endpoint
context=localphone-pjsip
aors=1652
auth=auth1652
transport=transport-wss
webrtc=yes
disallow=all
allow=ulaw
allow=alaw
dtls_cert_file=/etc/asterisk/key/asterisk.pem
dtls_private_key=/etc/asterisk/key/asterisk.key
[1652]
type = identify
endpoint = 1652
match = 123.123.123.123 ; the public IP of the VPS
The Asterisk debug log doesn’t show errors. The SIP session looks like this:
<--- Received SIP request (1175 bytes) from UDP:140.153.72.56:5060 --->
INVITE sip:136.46.324.75:5060 SIP/2.0
Record-Route: <sip:140.153.72.56;lr=on;ftag=gK086bb5a7>
Record-Route: <sip:126.219.52.41;lr;ftag=gK086bb5a7>
Via: SIP/2.0/UDP 140.153.72.56;branch=z9hG4bK356c.5360dbb7.0
Via: SIP/2.0/UDP 126.219.52.41:5060;rport=5060;branch=z9hG4bK356c.10463da.0
From: <sip:10782172281#126.219.52.41>;tag=gK086bb5a7
To: <sip:13051079265#localphone.com>;tag=514dc3ba-68ed-42ff-9733-bd65b8ebb7c7
Call-ID: 793253110_109248450#199.199.12.56
CSeq: 63984 INVITE
Max-Forwards: 12
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS,MESSAGE,PUBLISH
Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed
Contact: <sip:126.219.52.41;vbdid=941.29056c13>
Supported: timer
Session-Expires: 1800;refresher=uac
Min-SE: 90
Content-Length: 239
Content-Disposition: session; handling=required
Content-Type: application/sdp
v=0
o=Sonus_UAC 13229 650067 IN IP4 199.199.12.56
s=SIP Media Capabilities
c=IN IP4 199.199.12.54
t=0 0
m=audio 40808 RTP/AVP 0 100
a=rtpmap:0 PCMU/8000
a=rtpmap:100 telephone-event/8000
a=fmtp:100 0-15
a=sendrecv
a=maxptime:20
> 0x7fddf001b170 -- Strict RTP learning after remote address set to: 199.199.12.54:40808
<--- Transmitting SIP response (1062 bytes) to UDP:140.153.72.56:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 140.153.72.56;rport=5060;received=140.153.72.56;branch=z9hG4bK356c.5360dbb7.0
Via: SIP/2.0/UDP 126.219.52.41:5060;rport=5060;branch=z9hG4bK356c.10463da.0
Record-Route: <sip:140.153.72.56;lr;ftag=gK086bb5a7>
Record-Route: <sip:126.219.52.41;lr;ftag=gK086bb5a7>
Call-ID: 793253110_109248450#199.199.12.56
From: <sip:10782172281#126.219.52.41>;tag=gK086bb5a7
To: <sip:13051079265#localphone.com>;tag=514dc3ba-68ed-42ff-9733-bd65b8ebb7c7
CSeq: 63984 INVITE
Session-Expires: 1800;refresher=uac
Require: timer
Contact: <sip:136.46.324.75:5060>
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, REFER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Server: Asterisk PBX 15.6.1
Content-Type: application/sdp
Content-Length: 234
v=0
o=- 13229 650069 IN IP4 136.46.324.75
s=Asterisk
c=IN IP4 136.46.324.75
t=0 0
m=audio 10010 RTP/AVP 0 100
a=rtpmap:0 PCMU/8000
a=rtpmap:100 telephone-event/8000
a=fmtp:100 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
> 0x7fddf001b170 -- Strict RTP switching to RTP target address 199.199.12.54:40808 as source
<--- Received SIP request (411 bytes) from UDP:140.153.72.56:5060 --->
ACK sip:136.46.324.75:5060 SIP/2.0
Via: SIP/2.0/UDP 140.153.72.56;branch=z9hG4bK356c.5360dbb7.2
Via: SIP/2.0/UDP 126.219.52.41:5060;rport=5060;branch=z9hG4bK356c.10463da.2
From: <sip:10782172281#126.219.52.41>;tag=gK086bb5a7
To: <sip:13051079265#localphone.com>;tag=514dc3ba-68ed-42ff-9733-bd65b8ebb7c7
Call-ID: 793253110_109248450#199.199.12.56
CSeq: 63984 ACK
Max-Forwards: 12
Content-Length: 0
<--- Received SIP request (428 bytes) from WSS:152.231.162.25:53283 --->
BYE sip:asterisk#mail.example.com:5060;transport=ws SIP/2.0
Via: SIP/2.0/WSS qae9g3ug98cm.invalid;branch=z9hG4bK8418203
Max-Forwards: 70
To: <sip:10782172281#mail.example.com>;tag=46b408fd-815a-49c1-b337-74ee894d6e44
From: "Grant Brandon" <sip:6l78pghi#152.231.162.25>;tag=1l7sldm3o2
Call-ID: 4b8d773b-243b-4e97-9962-efc4d55eb0de
CSeq: 27946 BYE
Supported: outbound
User-Agent: SIP.js/0.7.8
Content-Length: 0
<--- Transmitting SIP response (376 bytes) to WSS:152.231.162.25:53283 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS qae9g3ug98cm.invalid;rport=53283;received=152.231.162.25;branch=z9hG4bK8418203
Call-ID: 4b8d773b-243b-4e97-9962-efc4d55eb0de
From: "Grant Brandon" <sip:6l78pghi#152.231.162.25>;tag=1l7sldm3o2
To: <sip:10782172281#mail.example.com>;tag=46b408fd-815a-49c1-b337-74ee894d6e44
CSeq: 27946 BYE
Server: Asterisk PBX 15.6.1
Content-Length: 0
-- Channel PJSIP/601-00000003 left 'simple_bridge' basic-bridge <f59afd46-1e16-4f47-9a9d-59c11987cc77>
-- Channel PJSIP/localphone-00000002 left 'simple_bridge' basic-bridge <f59afd46-1e16-4f47-9a9d-59c11987cc77>
== Spawn extension (localphone-pjsip, 601, 1) exited non-zero on 'PJSIP/localphone-00000002'
<--- Transmitting SIP request (487 bytes) to UDP:140.153.72.56:5060 --->
BYE sip:126.219.52.41;vbdid=941.29056c13 SIP/2.0
Via: SIP/2.0/UDP 136.46.324.75:5060;rport;branch=z9hG4bKPjf05b6f33-c9d2-4606-80d5-1e54fc110d40
From: <sip:13051079265#localphone.com>;tag=514dc3ba-68ed-42ff-9733-bd65b8ebb7c7
To: <sip:10782172281#126.219.52.41>;tag=gK086bb5a7
Call-ID: 793253110_109248450#199.199.12.56
CSeq: 13266 BYE
Route: <sip:140.153.72.56;lr;ftag=gK086bb5a7>
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 15.6.1
Content-Length: 0
<--- Received SIP response (335 bytes) from UDP:140.153.72.56:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 136.46.324.75:5060;rport=5060;branch=z9hG4bKPjf05b6f33-c9d2-4606-80d5-1e54fc110d40
From: <sip:13051079265#localphone.com>;tag=514dc3ba-68ed-42ff-9733-bd65b8ebb7c7
To: <sip:10782172281#126.219.52.41>;tag=gK086bb5a7
Call-ID: 793253110_109248450#199.199.12.56
CSeq: 13266 BYE
Content-Length: 0
Your help will be appreciated !

SOAP Onvif no response for WCF Client

I have camera that supports Onvif. Calling OnVif SOAP GetDeviceInformation
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
I get an answer when using SoapUI. I created simple WCF console app to call the same method - no answer from camera.
I checked with wireshart the messages sent:
SoapUI:
Frame 8858: 680 bytes on wire (5440 bits), 680 bytes captured (5440 bits) on interface 0
Ethernet II, Src: IntelCor_fc:da:96 (b4:b6:76:fc:da:96), Dst: Shenzhen_a4:9f:e8 (e8:ab:fa:a4:9f:e8)
Internet Protocol Version 4, Src: 10.0.0.8, Dst: 10.0.0.102
Transmission Control Protocol, Src Port: 61385, Dst Port: 888, Seq: 1, Ack: 1, Len: 626
Hypertext Transfer Protocol
POST /onvif/device_service HTTP/1.1\r\n
Accept-Encoding: gzip,deflate\r\n
Content-Type: application/soap+xml;charset=UTF-8;action="http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation"\r\n
Content-Length: 322\r\n
[Content length: 322]
Host: 10.0.0.102:888\r\n
Connection: Keep-Alive\r\n
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)\r\n
\r\n
[Full request URI: http://10.0.0.102:888/onvif/device_service]
[HTTP request 1/1]
[Response in frame: 8891]
File Data: 322 bytes
eXtensible Markup Language
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
WCF Client:
Frame 11631: 315 bytes on wire (2520 bits), 315 bytes captured (2520 bits) on interface 0
Ethernet II, Src: IntelCor_fc:da:96 (b4:b6:76:fc:da:96), Dst: Shenzhen_a4:9f:e8 (e8:ab:fa:a4:9f:e8)
Internet Protocol Version 4, Src: 10.0.0.8, Dst: 10.0.0.102
Transmission Control Protocol, Src Port: 61420, Dst Port: 888, Seq: 282, Ack: 1, Len: 261
[2 Reassembled TCP Segments (542 bytes): #11629(281), #11631(261)]
Hypertext Transfer Protocol
POST /onvif/device_service HTTP/1.1\r\n
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation"\r\n
Host: 10.0.0.102:888\r\n
Content-Length: 261\r\n
[Content length: 261]
Expect: 100-continue\r\n
Accept-Encoding: gzip, deflate\r\n
Connection: Keep-Alive\r\n
\r\n
[Full request URI: http://10.0.0.102:888/onvif/device_service]
[HTTP request 1/1]
File Data: 261 bytes
eXtensible Markup Language
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
Bellow WCF code after WSDL Onvif WSDL reference was added to project:
namespace OnVifInfo
{
class Program
{
static void Main(string[] args)
{
GetDeviceInfo(new Uri("http://10.0.0.102:888/onvif/device_service"));
}
private static void GetDeviceInfo(Uri uri)
{
string address = uri.AbsoluteUri.ToString();
var messageElement = new TextMessageEncodingBindingElement()
{
MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement()
{
AuthenticationScheme = System.Net.AuthenticationSchemes.Negotiate
};
CustomBinding binding = new CustomBinding(messageElement, httpBinding);
OnVifWebService.DeviceClient service = new OnVifWebService.DeviceClient(binding, new EndpointAddress(address));
string model;
string firmwareVersion;
string serialNumber;
string hardwareId;
var response = service.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId);
}
}
}
Any ideas why camera is not answering to WCF client?
Why there is reassemble line:
[2 Reassembled TCP Segments (542 bytes): #11629(281), #11631(261)]
in WCF client request, but not in SoapUI call
Problem was the Expect HTML header
Expect: 100-continue\r\n
When I added this to WCF code
System.Net.ServicePoint servicePoint = System.Net.ServicePointManager.FindServicePoint(service.Endpoint.Address.Uri);
servicePoint.Expect100Continue = false;
It removed the Expect header and I got the answer from the camera.

RESTEASY003200: Could not find message body reader for type: class org.glassfish.jersey.media.multipart.FormDataMultiPart

I want to upload image and send some parameters to my java rest service.I have added jersey-media-multipart to my pom.xml and I setted neccessary configurations to ApplicationConfig class. I am using Wildfly 11 for application server.But I am continuosly getting this exception.
11:29:36,199 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-35) RESTEASY002010: Failed to execute: javax.ws.rs.NotSupportedException: RESTEASY003200: Could not find message body reader for type: class org.glassfish.jersey.media.multipart.FormDataMultiPart of content type: multipart/form-data;boundary=--------------------------291101341234694996301314
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:53)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.security.doseta.DigitalVerificationInterceptor.aroundReadFrom(DigitalVerificationInterceptor.java:36)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:59)
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:151)
at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:92)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:115)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:213)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at com.mepsan.outra.global.LoginFilter.doFilter(LoginFilter.java:41)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
ApplicationConfig.java
#javax.ws.rs.ApplicationPath("resources")
public class ApplicationConfig extends Application {
.....
#Override
public Map<String, Object> getProperties() {
Map<String, Object> props = new HashMap<>();
props.put("jersey.config.server.provider.classnames",
"org.glassfish.jersey.media.multipart.MultiPartFeature");
return props;
}
}
MobileSource .java
#Path("mobile")
public class MobileSource {
#POST
#Path("profile/upload")
#Consumes(MediaType.MULTIPART_FORM_DATA)
public Response execute(FormDataMultiPart multi) {
}
}
pom.xml
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.19</version>
</dependency>
Another WAY
#POST
#Path("profile/upload")
#Consumes(MediaType.MULTIPART_FORM_DATA)
public Response execute(#FormDataParam("image") InputStream imgstream,
#FormDataParam("data") String s) {
//multi.getF
try {
System.out.println("S " + s);
byte[] imgdata = inputStreamToByte(imgstream);
//System.out.println("DATA STR " + data);
//System.out.println("THE PARAM " + mstr);
System.out.println("THE PARAM S " + imgdata.length);
} catch (IOException ex) {
Logger.getLogger(MobileSource.class.getName()).log(Level.SEVERE, null, ex);
}
return Response.ok().build();
}
When I use this way to handle request, I just see this obscure result in log.
13:07:09,911 INFO [stdout] (default task-41) S ----------------------------336065642279870055586849
13:07:09,911 INFO [stdout] (default task-41) Content-Disposition: form-data; name="data"
13:07:09,911 INFO [stdout] (default task-41)
13:07:09,911 INFO [stdout] (default task-41) test
13:07:09,911 INFO [stdout] (default task-41) ----------------------------336065642279870055586849
13:07:09,911 INFO [stdout] (default task-41) Content-Disposition: form-data; name="image"; filename="eagle.jpg"
13:07:09,911 INFO [stdout] (default task-41) Content-Type: image/jpeg
13:07:09,911 INFO [stdout] (default task-41)
13:07:09,911 INFO [stdout] (default task-41) ????.....
abstruse continue....
13:07:16,804 INFO [stdout] (default task-41) ----------------------------336065642279870055586849--
13:07:16,804 INFO [stdout] (default task-41)
13:07:16,804 INFO [stdout] (default task-41) THE PARAM S 0
FINISH
For people who face the same issue.This took my 2 days. We need to use jBoss RESTEasy's Multipart support because of our application server is JBOSS(I have learned it recently. By the way, I have used lots of Apache 3rd part library without using Apache Tomcat :p ). Anyway, we add our multipart provider dependency to our pom.xml
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.1.4.Final</version>
<scope>provided</scope>
</dependency>
We do nothing with ApplicationConfig class. And here is rest part
#POST
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Path("upload")
public Response up1(MultipartFormDataInput input) {
List<InputPart> jsonpart = input.getFormDataMap().get("jsondata");
List<InputPart> imgpart = input.getFormDataMap().get("image");
InputStream is2 = input.getFormDataPart("image", InputStream.class,null);
String jsonStr = input.getFormDataPart("jsondata", String.class,null);
}
That's all.

Asterisk modify headers

I want to replace my SPA2102 for asterisk. How can I modify headers, like From, To and Contact?
I need to replace headers, like
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as1ea48bca
To headers, like SPA2102.
My SPA2102 sends it like
"XXXX174264" <sip:XXXX174264#ip.ip.ip.6>
How
# tcpdump -nAieth0 port 5060 and net ip.ip.ip.0/24
10:47:55.801914 IP 10.37.93.21.5060 > ip.ip.ip.6.5060: SIP, length: 906
E....j..#...
%].............INVITE sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK20d7bc88
Max-Forwards: 70
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as1ea48bca
To: <sip:474264#ip.ip.ip.6>
Contact: <sip:XXXX174264#10.37.93.21:5060>
Call-ID: 6b4c893e70628a626286cd0a748f93de#ip.ip.ip.6
CSeq: 102 INVITE
User-Agent: Linksys/SPA2102-5.2.5
Date: Wed, 16 Jan 2013 04:47:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 333
v=0
o=- 233070007 233070007 IN IP4 10.37.93.21
s=Asterisk PBX 11.2.0
c=IN IP4 10.37.93.21
t=0 0
m=audio 10004 RTP/AVP 0 8 3 111 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv
10:47:55.822359 IP ip.ip.ip.6.5060 > 10.37.93.21.5060: SIP, length: 348
E..x..#.>.#.....
%]......d.CSIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK20d7bc88
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as1ea48bca
To: <sip:474264#ip.ip.ip.6>
Call-ID: 6b4c893e70628a626286cd0a748f93de#ip.ip.ip.6
CSeq: 102 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Content-Length: 0
I try to make call using SPA and Asterisk. Both register succes. But Asterisk can't make call.
Here is tcpdump from SPA:
00:58:00.778565 IP 10.37.93.23.5060 > ip.ip.ip.6.5060: SIP, length: 892
Eh..........
%].............INVITE sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: XXXX174264 <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>
Remote-Party-ID: XXXX174264 <sip:XXXX174264#ip.ip.ip.6>;screen=yes;party=calling
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 INVITE
Max-Forwards: 70
Contact: XXXX174264 <sip:XXXX174264#10.37.93.23:5060>
Expires: 240
User-Agent: Linksys/SPA2102-5.2.5
Content-Length: 268
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER
Supported: x-sipura, replaces
Content-Type: application/sdp
v=0
o=- 93383 93383 IN IP4 10.37.93.23
s=-
c=IN IP4 10.37.93.23
t=0 0
m=audio 16186 RTP/AVP 8 0 18 4 100
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729a/8000
a=rtpmap:4 G723/8000
a=rtpmap:100 NSE/8000
a=fmtp:100 192-193
a=ptime:20
a=sendrecv
00:58:00.782580 IP ip.ip.ip.6.5060 > 10.37.93.23.5060: SIP, length: 342
....E..r..#.>.#.....
%]......^..SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: "XXXX174264" <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Content-Length: 0
00:58:02.479539 IP ip.ip.ip.6.5060 > 10.37.93.23.5060: SIP, length: 683
....E.....#.>."p....
%].......<.SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: "XXXX174264" <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>;tag=109877804-3792792162-4082950052-3026001148
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Content-Type: application/sdp
Server: MERA MVTS3G v.4.3.0-38t
Content-Length: 258
v=0
o=- 1358621882 1358621882 IN IP4 ip.ip.ip.5
s=-
c=IN IP4 ip.ip.ip.5
t=0 0
m=audio 39878 RTP/AVP 8 0 18
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=ptime:20
a=sendrecv
a=silenceSupp:off - - - -
00:58:30.832778 IP 10.37.93.23.5060 > ip.ip.ip.6.5060: SIP, length: 339
Eh.o........
%]..........[O.CANCEL sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: XXXX174264 <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 CANCEL
Max-Forwards: 70
User-Agent: Linksys/SPA2102-5.2.5
Content-Length: 0
00:58:30.836782 IP ip.ip.ip.6.5060 > 10.37.93.23.5060: SIP, length: 385
....E.....#.>.#.....
%].......7.SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: "XXXX174264" <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>;tag=109877804-3792792162-4082950052-3026001148
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 CANCEL
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Content-Length: 0
00:58:30.838775 IP ip.ip.ip.6.5060 > 10.37.93.23.5060: SIP, length: 450
....E.....#.>.#Y....
%].........SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: "XXXX174264" <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>;tag=109877804-3792792162-4082950052-3026001148
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Reason: SIP;cause=487;text="Request Terminated"
Content-Length: 0
00:58:30.845777 IP 10.37.93.23.5060 > ip.ip.ip.6.5060: SIP, length: 437
Eh.........&
%].............ACK sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.23:5060;branch=z9hG4bK-9b906813
From: XXXX174264 <sip:XXXX174264#ip.ip.ip.6>;tag=e9377d83dbc079fo0
To: <sip:474264#ip.ip.ip.6>;tag=109877804-3792792162-4082950052-3026001148
Call-ID: 27e34e53-cdeded0f#10.37.93.23
CSeq: 101 ACK
Max-Forwards: 70
Contact: XXXX174264 <sip:XXXX174264#10.37.93.23:5060>
User-Agent: Linksys/SPA2102-5.2.5
Content-Length: 0
And tcpdump from Asterisk:
E...W,..#. .
%].............INVITE sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK6422ee1e
Max-Forwards: 70
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as43ada6c8
To: <sip:474264#ip.ip.ip.6>
Contact: <sip:XXXX174264#10.37.93.21:5060>
Call-ID: 6e8b22967d9c55ea349abb636c0e5263#ip.ip.ip.6
CSeq: 102 INVITE
User-Agent: Linksys/SPA2102-5.2.5
Date: Sat, 19 Jan 2013 18:49:27 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 333
v=0
o=- 413424664 413424664 IN IP4 10.37.93.21
s=Asterisk PBX 11.2.0
c=IN IP4 10.37.93.21
t=0 0
m=audio 10008 RTP/AVP 0 8 3 111 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv
00:49:27.073977 IP ip.ip.ip.6.5060 > 10.37.93.21.5060: SIP, length: 348
E..x..#.>.#.....
%]......d..SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK6422ee1e
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as43ada6c8
To: <sip:474264#ip.ip.ip.6>
Call-ID: 6e8b22967d9c55ea349abb636c0e5263#ip.ip.ip.6
CSeq: 102 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Content-Length: 0
00:49:27.100102 IP ip.ip.ip.6.5060 > 10.37.93.21.5060: SIP, length: 478
E.....#.>.#?....
%].........SIP/2.0 603 Subscriber account disabled
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK6422ee1e
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as43ada6c8
To: <sip:474264#ip.ip.ip.6>;tag=179071226-3792791650-4082950052-3026001148
Call-ID: 6e8b22967d9c55ea349abb636c0e5263#ip.ip.ip.6
CSeq: 102 INVITE
Contact: <sip:474264#ip.ip.ip.6:5060>
Server: MERA MVTS3G v.4.3.0-38t
Reason: Centrex;cause=179;text="Subscriber account disabled"
Content-Length: 0
00:49:27.100295 IP 10.37.93.21.5060 > ip.ip.ip.6.5060: SIP, length: 433
E...W-..#.
.
%]...........#,ACK sip:474264#ip.ip.ip.6 SIP/2.0
Via: SIP/2.0/UDP 10.37.93.21:5060;branch=z9hG4bK6422ee1e
Max-Forwards: 70
From: "asterisk" <sip:XXXX174264#ip.ip.ip.6>;tag=as43ada6c8
To: <sip:474264#ip.ip.ip.6>;tag=179071226-3792791650-4082950052-3026001148
Contact: <sip:XXXX174264#10.37.93.21:5060>
Call-ID: 6e8b22967d9c55ea349abb636c0e5263#ip.ip.ip.6
CSeq: 102 ACK
User-Agent: Linksys/SPA2102-5.2.5
Content-Length: 0
Try change in sip.conf following:
[general]
realm=yourprovider-domain-here
useragent = Linksys/PAP2T-5.1.6(LS)
sdpsession= Linksys/PAP2T-5.1.6(LS)
you can use SipAddHeader in dialplan, like
SipAddHeader(P-Preferred-Identity: <sip:XXXXXX#10.0.10.10>
There are two places where you can change these headers.
In your PBX for calls in the sense PBX -> SPA you should modify your sip.conf file like that:
[general]
...
realm = my_realm.com ; This will substitute From: "asterisk"
In your SPA2102 for calls in the sense SPA -> PBX you have to enter the SPA configuration and change your subscriber information. This is step 5 of this guide: http://www.voipvoip.com/spa-2101/ where it says "Display Name"