ACK message not routes when running opensips as mid_resistrar for freeswitch - freeswitch

This is my first time using opensips, so am probably missing something obvious.
I am trying to use opensips and mid_registrar in front of freeswitch. The opensips is behind a NAT so I am setting the advertised_address to my public IP. The registrations work Ok, but an invite goes through the auth required but the ACK from the client is not routed back to the freeswitch server, instead going to the public interface.
I am using a modified version of the sample for the mid_registrar tutorial, mainly changes for 3.3 as the script is for 2.x.
It seems that the loose_route() is returning true but the $du is not being modified. If I hack to set the $du for both ACK and BYE to the freeswitch ip then the call completes Ok (still have rtp issues, but that comes next).
In the attached https://pastebin.com/Pz3anhYb
it all goes a bit pear shaped at 2022/11/28 12:17:42.170560
In the attached https://pastebin.com/siCZDEt2
if I enable line 142 to modify $du it gets one step further.
I am familiar with SIP but not at this level.
(sorry can't seem to add file links without making then code)

Most likely, FreeSWITCH is discarding the ACK because you are manually modifying the Request-URI, leading to a URI it does not recognize anymore. Notice the difference:
200 OK Contact header from FS contains sip:1008#115.188.133.253:5060;transport=udp
The ACK sent to FS contains sip:115.188.133.253;lr as Request-URI (??)
To fix this, you should use the "route recording" mechanism specific to SIP RFC 3261, where the mid-registrar effectively records itself in the path of mid-dialog requests, rather than achieving this through some hardcoded-behavior in your UAC (e.g. "Why is the ACK sent to 192.168.1.238 in the first place? SIP-wise, it should go directly to 115.188.133.253!").
Concretely, call record_route() before mid_registrar_lookup() on your initial INVITEs.

Related

CORs rule not found when putting data in azure storage

So I have a site where I upload large video files using html 5 to azure storage using an sas signature. It seems to work fine on most systems and browsers but doesn't seem to work on iPhones. I finally routed the call through fiddler via proxy and got the response from the storage server.
Here is the CORs rule I have set up.
What am I missing here?
Good evening,
There are a few things I would like you to try simultaneously, when you get a chance:
1. Change your Allowed Headers to: "Origin,X-Requested-With,Content-Type,Accept,Authorization,Accept-Language,Content-Language,Last-Event-ID,X-HTTP-Method-Override, x-ms-*". NOTE: You may not need all of these, but for now, add them all to see if we can get it working.
2. Change your Allowed Methods to: NONE, PUT, OPTIONS
3. Set the Max Age (seconds) field to 0
4. Create another rule, and do not have a comma-separated list of allowed origins. Make a separate rule for each origin. (I've heard of certain browsers not liking the CSV).
Once all is said and done, if the above does not work, try removing "Authorization" from the allowed headers since it looks like you are not using that (but first, try it with it).
Please let me know if you make any progress with the above ideas.

BackgroundTransferService: what are some of the details of its operation?

I kick off 5 uploads (of varying size) via the BackgroundTransferService. I have the following questions about the way it works:
It seems that on the emulator it does 2 uploads at a time. Is this how it works on the actual device? Can I programmatically change this behavior?
Can I count on the uploads going out in the order that I submitted them? I seem to be getting conflicting results in my testing.
When I inspect the BackgroundTransferService in my application, does it contain requests from other apps as well or just mine?
Do I need to reconnect events for all the BackgroundTransferRequest objects when coming back from being tombstoned? What about coming back from being reactivated?
Do I need to disconnect events from the BackgroundTransferRequest when I remove it from the BackgroundTransferService.Requests collection?
When I try to upload a non-existing URL:Port (on the localhost), the TransferStatus is reported as WaitingForNonVoiceBlockingNetwork. The upload never actually completes/fails. Is this how it is on the device? Should I remove the request when it encounters this TransferStatus?
You cannot influence the behaviour of the BTS. If you don't like the way it works you can write the transfer functionality as part of your own application but then you have to handle running in the background yourself.
There is no guarantee on sequence.
The BTS may be handling requests from other apps but you won't be able to see the details. Requests() will only return details for your app.
Surely a quick test will tell you this.
It's good practice to.
Have you checked the TransferError property whe you reach this situation? This is a perfectly valild status in other situations and so you shouldn't treat this as a automatic fail.

[OSX Core Foundation]How can I asynchronously upload a file though HTTP and get a callback called while sending bytes of the stream?

on MacOSX, with Core Foundation, I want to upload a large file (several hundreds of megabytes) to a remote server through a REST API.
Since the file is big and I also need to give the user some feedback, I want to implement a resume upload feature and gives the user feedback on the number of bytes written.
I first followed the Apple Guide for CFNetwork programming: http://developer.apple.com/library/ios/#documentation/Networking/Conceptual/CFNetwork/CFFTPTasks/CFFTPTasks.html#//apple_ref/doc/uid/TP30001132-CH9-SW1
But the asynchronous upload of file is for FTP only.
I tried to use CFReadStreamCreateForHTTPRequest butI only got callbacks on response.
I tried with CFReadStreamCreateForHTTPStreamedRequest and I set a delegate on the ReadStreamRef body parameter but it is never called even though I open the stream before actually scheduling it on the runloop.
If somebody has some tips about how to do it, it would be great.
Thanks a lot!
--
Rémy
I got an answer here: http://lists.apple.com/archives/macnetworkprog/2010/Dec/msg00000.html.
CFReadStreamCreateForHTTPStreamedRequest is the good function to use.
For upload feedback, I use a timer scheduled on the runloop when creating the request:
CFRunLoopTimerCreate(kCFAllocatorDefault, 0, 10.0, 0, 0, ...);
For resume, there are two steps.
Seek the local content stream at the good offset
Once the local content stream created (but not yet opened), I can seek in it using
CFReadStreamSetProperty(content_stream, kCFStreamPropertyFileCurrentOffset, uploaded_length);
Configure http headers
I don't have webdav style remote server, so I use HTTP Range headers to inform the server about which part of the file I want to upload. This step depends on what the remote server expects.
CFHTTPMessageSetHeaderFieldValue(request_headers, CFSTR("Range"), content_range_value);
Hope this will help.

Where is Firefox's URL processor?

After 3 days digging in this Mozilla NSS and the Firefox source codes (and some extensions and running the SSLsample codes too), I'm clearly lost now.
My intention is just to do simple thing. To divert any https request from Firefox to my very own callback functions. In which, my callbacks here have some information for the NSS/SSL to work with.
My only problem is, where is Firefox's code for processing the https URL. I mean, when we key in the https address at the address bar, we press Enter. I just need access to the source that triggers at that point (after we press Enter). Somehow, I can intercept any request for https URLs.
Thanks.
So, you want to intercept the data, right? You'll want to play around with this interface.
not sure, if it helps, but I asked this question:
XULRunner: Prevent links to arbitrary domains
Maybe it could be sufficient for your task to use the method explained in the first answer. However, it is an all-JavaScript solution.
Cheers,

How to "stream" json from server to client using javascript

I'm familiar enough with Ajax and JSON that I can send a request and get a parse a JSON request. Ideally I'd like to receive multiple response to periodically update a progress bar. This way clients can have a positive feedback.
I've heard of JSON streams but have not found a good resource on how to implement this. Does anyone know of a good resource or how to do this?
JSON is just yet another format of data going over the HTTP protocol (like text, html, pdf, etc). You are probably referring to cometd.
This allows you to open a persistent connection and push data from the server to the client (ie stream it). Any format is valid to push, the client just needs to understand it.
Found a technique called page streaming.
Basically you write <script>some js</script> entries into the persistent connection and flush them into the network interface. As browser receives that, it will parse and execute the script.
Try looking into the library "comet." It's implements what's known as "reverse AJAX." It'll allow you to send events from the server to the client easily.
The polling suggestion made just before mine, is also perfectly valid.
<script language="JavaScript">
function doSomething() {
// do something here...
}
setInterval('doSomething()',10000);
<script>
That will call a function every 10 seconds. So you can poll the server every 10 seconds (or 1 second) to get a response on the status of whatever event you're trying to track. Simply put your AJAX call inside that function and it'll send.

Resources