fail to forward bye when using mobicents proxy - restcomm

when testing proxy in mobicents, mobicents cannot forward bye message to the other one.
when one user send bye, it just receives 481 and the other user remains in talking.
Such exception only occurs when call duration >= 10s.
and i can see that sip application session is closed before user send bye. i dont konw how to avoid this.
please help me !!!
below is my test code:
#Override
protected void doInvite(SipServletRequest request) throws ServletException, IOException {
List<SipURI> forks = new ArrayList<SipURI>();
SipURI toURI = (SipURI) request.getTo().getURI();
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
forks.add( sipFactory.createSipURI(toURI.getUser(),"192.168.4.160:11180") );
forks.add( sipFactory.createSipURI("9988003","192.168.4.30:5080") );
//request.getProxy().setParallel(true);
List<ProxyBranch> branches = request.getProxy().createProxyBranches( forks );
for(ProxyBranch branch: branches){
branch.setRecordRoute(true);
}
request.getProxy().startProxy();
}
and i get an exception in my log:
org.mobicents.servlet.sip.core.DispatcherException: Cannot find the corresponding sip application session to this subsequent request BYE sip:9988002#192.168.4.160:11180;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.4.204:11180;rport=11180;branch=z9hG4bKBH36Ht963rXeB;received=192.168.4.204
Max-Forwards: 70
From: "Extension 9988001" <sip:9988001#192.168.4.204>;tag=KtgZ29USetpNj
To: <sip:9988002#192.168.4.89>;tag=vN8t8Xm8yXg2K
Call-ID: 0e0bee76-943b-1234-4ba8-000c29680286
CSeq: 91266548 BYE
Contact: <sip:mod_sofia#192.168.4.204:11180>
User-Agent: FreeSWITCH-mod_sofia/1.2.23~64bit
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REGISTER,REFER,NOTIFY
Supported: timer,path,replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0
with the following popped route header <sip:192.168.4.89:5060;transport=udp;as=ded31d5f-500e-4c2d-84bb-370065d85c87;appname=1180947b;proxy=true;app_id=7599adf4;lr>, it may already have been invalidated or timed out
at org.mobicents.servlet.sip.core.dispatchers.SubsequentRequestDispatcher.dispatchMessage(SubsequentRequestDispatcher.java:248)
at org.mobicents.servlet.sip.core.SipApplicationDispatcherImpl.processRequest(SipApplicationDispatcherImpl.java:861)
at gov.nist.javax.sip.EventScanner.deliverRequestEvent(EventScanner.java:250)
at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:146)
at gov.nist.javax.sip.SipProviderImpl.handleEvent(SipProviderImpl.java:185)
at gov.nist.javax.sip.DialogFilter.processRequest(DialogFilter.java:1324)
at gov.nist.javax.sip.stack.SIPServerTransactionImpl.processRequest(SIPServerTransactionImpl.java:811)
at gov.nist.javax.sip.stack.UDPMessageChannel.processMessage(UDPMessageChannel.java:578)
at gov.nist.javax.sip.stack.UDPMessageChannel.processIncomingDataPacket(UDPMessageChannel.java:524)
at gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:319)
at java.lang.Thread.run(Thread.java:722)

Is this happening only for calls whose duration is > 3 minutes ?
The sip servlets specification defines the default duration for sip session to be 3 minutes. You can modify it in the sip.xml session-timeout attribute or programatically in your app.

Related

Ktor Android Client Websocket Connection Failed

The WebSocket server is a online testing one
The Website
Something goes wrong And I don't know how to fix it.
val client = HttpClient(CIO) { install(WebSockets) }
GlobalScope.launch {
client.webSocket("ws://82.157.123.54:9010/ajaxchattest") {}
}
the error printStackTrace
java.lang.IllegalStateException: Failed to parse request body: request body length
should be specified,
chunked transfer encoding should be used or
keep-alive should be disabled (connection: close)
not knowing how to enable encoding or disable keep-alive or specify body length.
The 82.157.123.54:9010/ajaxchattest endpoint responds with 403 Forbidden instead of 101 Switching Protocols if the Origin header is absent or invalid. So to make it work just append the Origin header with a well-formed value:
val client = HttpClient(CIO) { install(WebSockets) }
client.webSocket("ws://82.157.123.54:9010/ajaxchattest", request = {
header(HttpHeaders.Origin, "http://example")
}) {}

NodeRED http-response node: How to stop NodeRED adding charset to content-type?

I need to build a http proxy for a jpeg image inside NodeRED. My goal is that the browser does get all page resources in the dashboard from the NodeRED server. And the image is only available from another server.
I tried this abstract flow:
http-in -> http-request -> function node -> http response
In the function node I set the headers:
msg.headers = {
"content-type": "image/jpeg",
"content-disposition": "inline; filename=\"myimage.jpg\""
}
The problem is, that the browser gets these headers (excerpt):
content-type: image/jpeg; charset=utf-8
content-disposition: inline; filename="myimage.jpg"
Where the hell is charset=utf-8 coming from and how to stop NodeRED adding this?
You do not mention what msg.payload is set to in your flow.
If the msg.payload you pass to the HTTP Response node is a String, the content type gets the charset parameter added. This isn't deliberate behaviour of Node-RED - but something happening in the underlying http/express framework.
If msg.payload is a Buffer object, then no such parameter is added.
charset=utf-8, is added by node-red to define the standard there will be no issue if headers added charset on it.

Inserting client certificates into an HTTPS POST request

I'm building a hardware device which connects to the AWS IOT platform. According to the documentation the authentication with the aws iot platform is done with TLS. I have the Root CA, client key and client certificate files on the device that authorize the access. Is there a way to use these files in the HTTP header while making the POST request? If so, how? So far here is the code for the Energia IDE (based on the Arduino IDE) and using the WiFiClient methods.
if (client.sslConnect(aws_endpoint, 443))
{
Serial.println("\nConnected to AWS endpoint");
String PostData = "{\"value1\" : \"testValue\", \"value2\" : \"Hello\", \"value3\" : \"World!\" }";
request = "POST /things/";
request += thingname;
request += "/shadow";
request += " HTTP/1.1";
Serial.print("Request:\t"); Serial.println(request);
Serial.print("Post data:\t"); Serial.println(PostData);
client.println(request);
client.println("Host: ");
client.println(aws_endpoint);
client.println(":443");
client.println("User-Agent: Energia/1.1");
client.println("Connection: close");
client.println("Content-Type: application/json");
client.print("Content-Length: "); client.println(PostData.length());
client.println();
client.println(PostData);
client.println();
}
else
{
Serial.println("Connection failed");
}
Serial.println();
Serial.println("Server response:");
Serial.println();
// Capture response from the server. (10 second timeout)
long timeOut = 5000;
long lastTime = millis();
while((millis()-lastTime) < timeOut)
{ // Wait for incoming response from server
while (client.available())
{ // Characters incoming from the server
char c = client.read(); // Read characters
Serial.write(c);
}
}
This however, gives an authentication error:
HTTP/1.1 403 Forbidden
content-type: application/json
content-length: 91
date: Tue, 26 Jul 2016 11:46:59 GMT
x-amzn-RequestId: 4d5388a9-e3c4-460a-b674-c3f971f3330d
connection: Keep-Alive
x-amzn-ErrorType: ForbiddenException:
{"message":"Missing Authentication Token","traceId":"4d5388a9-e3c4-460a-b674-c3f971f3330d"}
The TLS client certificates would be sent/used as part of your client.sslConnect() call, not as part of the HTTP request. The TLS handshake (and exchange/validation of client and server certificates) happens before any HTTP message is sent.
This AWS forums post suggests that you may need to be using port 8443 (not port 443), for the shadow API. It looks like the use/requirement of TLS mutual authentication (via certificates), versus the use of AWS SIGv4 headers, is determined by AWS IOT based on the port used.
Hope this helps!

Migrating to self hosted Parse Server isn't giving me the logged user

I'm trying to migrate my Parse server to my own server instance in DigitalOcean. After deploying my parse-server I'm falling in some issue I can't understand.
When you make a call to the Cloud Code, you can retrieve your user as request.user if you have revocable sessions enabled.
Everything is OK, but sometimes (random times) I get this strange behaviour: my request.user doesn't appear in Cloud Code.
I thought it could be a bad session token so I got rid of it by doing:
if (!request.user) {
response.error("INVALID_SESSION_TOKEN");
return;
}
and obbligate the user to log-in again.
This wasn't working, I was getting an INVALID_SESSION_TOKEN everytime I log in, so I decided to debug. These are my steps:
1.- Log in my user, so a _Session object is created:
so the sessionToken is r:a425239d4184cd98b9b693bbdedfbc9c
2.- Make call cloud function (sniff log):
POST /parse-debug/functions/getHomeAudios HTTP/1.1
X-Parse-OS-Version: 6.0.1
X-Parse-App-Build-Version: 17
X-Parse-Client-Key: **** (hidden)
X-Parse-Client-Version: a1.13.0
X-Parse-App-Display-Version: 1.15.17
X-Parse-Installation-Id: d7ea4fa0-b4dc-4eff-9b7d-ff53a1424dcb
User-Agent: Parse Android SDK 1.13.0 (com.pronuntiapp.debug.uat/17) API
Level 23
X-Parse-Session-Token: r:a425239d4184cd98b9b693bbdedfbc9c
X-Parse-Application-Id: **** (hidden)
Content-Type: applicati¡á“WÇX�
Content-Length: 346
Host: 46.101.89.192:1338
Connection: Keep-Alive
Accept-Encoding: gzip
3.- request.user is still not appearing on CloudCode.
EDIT: Reseting the parse-server worked in this case, but not in some others.
Days ago I got the solution.
When you have successfully deployed your Parse server, you will get request.user from any end point of the cloud, but if you call a cloud function from cloud, you won't get this request.user at least you pass the sessionToken:
Parse.Cloud.define("foo", function(request, response) {
if (!request.user) {
response.error("INVALID_SESSION_TOKEN");
return;
}
var countResponses = 0;
var responsesNeeded = 1;
Parse.Cloud.run('bar', request.params, {
sessionToken: request.user.getSessionToken(),
success: function(c) {
countResponses++;
result = c;
if (countResponses >= responsesNeeded) {
response.success(result);
}
},
error: function(error) {
response.error(error);
}
});
});
in this case, foo will have request.user and bar won't, unless you pass sessionToken.

CANDY chat with Openfire : receiving empty response while connecting to a autologin chat room

I finally have the openfire server installed - admittedly noob to XMPP - but I'm getting there :)
I modified the .htaccess & now trying to hit the http://166.xx.xx.xx/candy-chat-candy-ca544b1/example/index.html on my server
The page shows me a "connecting.." message and hangs there.
Here is my setup before I delve into the firebug post/response.
I've modified the example/index.html as such :
$(document).ready(function() {
Candy.init('http://166.xx.xx.xx:7070/http-bind/', {
core: { debug: true },
autojoin: ['Opentalk#conference.166.xx.xx.xx'],
view: { language : 'en' }
});
Candy.Core.connect('166.xx.xx.xx', null, 'Guest'); // Connect anonymously to a specific server
});
In firebug, I see that the response is empty. However the post entry in firebug shows a 200 OK
And firebug complains (which I think is because the response is empty) --> "
XML Parsing Error: no element found Location:
moz-nullprincipal:{80250471-6b20-4144-ad88-92777a926018} Line Number
1, Column 1:
Here is the post
<body rid='3954428912' xmlns='http://jabber.org/protocol/httpbind' to='166.xx.xx.xx' xml:lang='en' wait='60' hold='1' content='text/xml;
charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
Since my debug is turned on, I see the same message as post :
SENT: <body rid='3954428912' xmlns='http://jabber.org/protocol/httpbind' to='166.xx.xx.xx' xml:lang='en' wait='60' hold='1' content='text/xml;
charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
Note : The only difference I see in my configuration is the the cross-domain part.
The setup screenshot shown on github has this field empty, while mine has the default entry, I don't know if that is in fact a problem though.
I'm doing something wrong, but can't put a finger as to what..
Any pointers about debugging further would be great !
----------------+++++++++++--------------
Update 2/1 **
Thanks Michael, seems making the changes has taken it a step forward !!
Now I'm getting a grey page instead of hanging at "connecting..".
Seems the connection is now being established. I'm not sure if the PrivacyListError is critical (correct me).
I looked into the candy.js & seems that if the list doesn't exist it'll create one.
The next error does seem critical, since it talks about service unavailable..
Success
SENT: <body rid='2569503371' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'><iq type='set' id='_session_auth_2' xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq></body> RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client' type='result' id='_session_auth_2' to='b967c785#myservername.com/b967c785'/></body>
[Connection]
Connected [Jabber]
Anonymous login
[Connection] Attached
Success
POST http-bind/ 200 OK 101ms
SENT: <body rid='2569503372' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'><presence xmlns='jabber:client'/><iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:private'><storage xmlns='storage:bookmarks'/></query></iq><iq type='get' from='b967c785#myservername.com/b967c785' id='get1' xmlns='jabber:client'><query xmlns='jabber:iq:privacy'><list name='ignore'/></query></iq></body>
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client' type='result' to='b967c785#myservername.com/b967c785'><query xmlns='jabber:iq:private'><storage xmlns='storage:bookmarks'/></query></iq></body>
[Jabber] Bookmarks
Error
POST http-bind/ 200 OK 56ms
SENT: <body rid='2569503373' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client' type='error' id='get1' to='b967c785#myservername.com/b967c785'><query xmlns='jabber:iq:privacy'><list name='ignore'/></query><error code='503' type='cancel'> <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq></body>
[Jabber] PrivacyListError
Error - this seems more serious
POST http-bind/ 200 OK 74ms
SENT: <body rid='2569503374' xmlns='http://jabber.org/protocol/httpbind'
sid='b967c785'><iq type='set' from='b967c785#myservername.com/b967c785' id='set1'
xmlns='jabber:client'><query xmlns='jabber:iq:privacy'><list name='ignore'><item
action='allow' order='0'/></list></query></iq><iq type='set'
from='b967c785#myservername.com/b967c785' id='set2' xmlns='jabber:client'><query
xmlns='jabber:iq:privacy'><active name='ignore'/></query></iq></body>
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client'
type='error' id='set1' to='b967c785#myservername.com/b967c785'><query
xmlns='jabber:iq:privacy'><list name='ignore'><item action='allow' order='0'/></list>
</query><error code='503' type='cancel'><service-unavailable
xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq></body>
Error - Last one, before it kinda hangs in the there
POST http-bind/ 200 OK 60ms
SENT: <body rid='2569503375' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns='jabber:client'
type='error' id='set2' to='b967c785#myservername.com/b967c785'><query
xmlns='jabber:iq:privacy'><active name='ignore'/></query><error code='503' type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq></body>
Last ajax call fired
POST http-bind/ 200 OK 60167ms
SENT: <body rid='2569503376' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind'/>
POST http-bind/
SENT: <body rid='2569503377' xmlns='http://jabber.org/protocol/httpbind' sid='b967c785'/>
Your http-bind url seems to be wrong as well as the autojoin and the first param of the connect function call.
If you configured the HTTP Proxy configuration correctly, the standard example/index.html should work.
You only need to change/add the autojoin param and change the connect function call.
Regarding the autojoin parameter: You configured a virtualhost on the XMPP server. You need to use this one as the hostname, not the IP. So it would look like autojoin: ['Opentalk#conference.example.com'].
The same applies to the first parameter of connect() you need to provide the virtual hostname of the XMPP Server.