Unified Messaging - Connecting OCS to the rest of the world!!
Posted by Ken Stauffer on Tue, Oct 12, 2010 @ 10:17 AM
OCS 2007/Lync 2010 is a great unified communications product, but one limiting factor has been the inability to connect devices via UDP. Microsoft says that they limit the connections to TCP only devices for security purposes. This article is not a commentary on why, but a discussion of how to overcome this limitation. Also, this shows 2 methods to connect to asterisk, but the sip proxy should work with many other IP PBX systems as well, and almost everything can connect to asterisk, so with these tools we should be able to connect to just about everything out there.
There are two technical hurdles to overcome, one is the convert the UDP message to TCP, which is easy, the other is to interpret and handle a 302 moved temporarilly message sent from OCS. You can connect via a commercial sip proxy, but of course they are expensive. Many other sites have posted how to do this with SER, another sip proxy. Internally at STI we have been successful with two open software approaches, both are well tested, easy, and very stable One is a shareware sip proxy named repro, and the other is via the built in TCP support in asterisk 1.6.
Using Repro
Repro is part of the ReSiprocate project, is available for download as source, and although you have to build it for windows, it comes with scripts and is really easy to do. This is a very stable product that requires a separate machine (cant run directly on the OCS server) . It is a little tricky to get working, but once you do it just runs and never crashes or causes problems.
You can download a non supported copy of repro that was compiled for windows by us here.
after you run install you can start repro with a command line similar to (please note the ip is the ip of the machine this proxy is running on)
repro --disable-auth --recursive-redirect --record-route=sip:192.168.42.2 --force-record-route --admin-password=admin --log-level=DEBUG > c:\reprout
Then you can log in and configure on port 5080 of your local machine with the url localhost:5080

Then set up Domains: I found you need to add three ip addresses, this proxy, the OCS server or edge server, and Asterisk server.

Once the 3 domains are added all you have to do is to add a route each direction to tell repro which protocol it expects.
We need all traffic to the OCS server to be TCP, and anything to the asterisk server to be UDP. In this case the ip of the asterisk box it 192.168.2.118, so our uri would be look like
^sip:(.*)@192.168.2.118
and its destination would look like
sip:$1@192.168.2.118;transport=udp

So once you have both routes set up, restart repro and it should work ok! If not look in the log file and you should be able to see whats wrong.
Repro full instruction page is located here.
Also, you should have repro start as a service, which is also very easy, just use srvany, directions from Microsoft are here.
Using Asterisk 1.6
For direct connection from Asterisk I have tested with Trixbox, and as long as you use the 1.6 version it connects just fine. As almost everything out there can connect to Asterisk, this interface should be able to bridge the gap to just about anybody out there. Connection is really straightforward (probably more than one way to accomplish this, but this one is well tested). You set up a trunk. You merely have to tell asterisk it's ok to use TCP and also about the 302 message, which it calls promiscuous redirect. the username is not important, but you have to put something. In your trunk settings enter something like the following:
canreinvite=yes
context=from-internal
host=IP-OF-OCS-Machine
username=3335
qualify=yes
transport=tcp,udp
promiscredir=yes
type=peer
thats all you need, feel free to post a comment below if you have a problem, or find an error! Also please let me know if you have found other ways to make this work!!