Anyone using MJ with own Asterisk server?

magicJack Tips and Tricks

Moderators: Bill Smith, Pilot

Post Reply
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Anyone using MJ with own Asterisk server?

Post by cohomology »

I'm trying to configure MJ to work with my own asterisk server(PBX in a flash) in order to have more features, like caller id lookup, blocking, etc. .

I wouldn't believe it's as easy as extracting the sip credentials and using that as a trunk. There must be sth. like MJMD5 to work in between the PBX and the trunk, IMHO. Has anyone tried this? Did you have luck?

TIA!
RonV
magicJack Apprentice
Posts: 14
Joined: Mon Dec 08, 2008 2:13 pm

Post by RonV »

jaybob413
MagicJack Newbie
Posts: 6
Joined: Mon Mar 23, 2009 9:30 am

Post by jaybob413 »

I am currently running PIAF with MagicJack. You will need the mjproxy daemon running somewhere to do the nonce twirling.

Replace NXXNXXXXXX in the example below with your 10 digit phone number, MJ20CHARACTERPASSWD with your password, and MJPROXYIP with the IP address of the server running mjproxy. This might be your Asterisk box or an OpenWRT or DD-WRT router (I have had it working with both).

The remaining steps are:

1) Using FreePBX, Set up a trunk for your MJ.


Trunk Name: MagicJack
PEER Details:
username=ENXXNXXXXXX01
type=friend
secret=MJ20CHARACTERPASSWRD
qualify=2000
port=5070
nat=yes
insecure=very
host=MJPROXYIP
fromuser=ENXXNXXXXXX01
dtmfmode=inband
context=from-trunk


Register String
ENXXNXXXXXX01:MJ20CHARACTERPASSWRD@MJPROXYIP:5070/NXXNXXXXXX


2) Create an Outbound Route to call out on. I set my Dial Pattern so dialing 8 uses MagicJack, 9 uses GV, etc. Pick whatever you want here.

Outbound Route
Dial Patterns
8|.
Trunk Sequence
SIP/MagicJack


3) Configure Inbound Routing
Inbound Route
DID Number: NXXNXXXXXX

Hope this helps.
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Post by cohomology »

Thank you jaybob413 for the instruction.

Seems your solution needs MJMD5 to run on a router. What if the PBX box is not behind a router? In fact, my scenario is that I'm running a hosted PBX virtual server.

So I gather my question boils down to: is there an MJMD5 port to i386 platform?
oldtimercurt
Dan isn't smart enough to hire me
Posts: 281
Joined: Sat Feb 07, 2009 11:45 am
Location: Pensacola

Post by oldtimercurt »

cohomology

I'll admit I don't totally understand what you are doing but how about the original MJMD5 such as I'm presently using on my Thin Client.

It will probably take some work to find it--I'm not very successful with the search function here.

OTC
jaybob413
MagicJack Newbie
Posts: 6
Joined: Mon Mar 23, 2009 9:30 am

Post by jaybob413 »

cohomology wrote:Thank you jaybob413 for the instruction.

Seems your solution needs MJMD5 to run on a router. What if the PBX box is not behind a router? In fact, my scenario is that I'm running a hosted PBX virtual server.

So I gather my question boils down to: is there an MJMD5 port to i386 platform?
I compiled the mjproxy source and am running it on the PIAF box. I did run it on a router at one time, but have since moved it to the same box that Asterisk is running on. The router is just redirecting the IAX, SIP, and RTP UDP ports to the PIAF box which allows me to use the public ip address of the router to accept SIP URI addresses to connect.

If you search for mjproxy, you should be able to download the source, compile it, and set up run scripts to start it on boot. They are different that the ones that are posted for OpenWRT/DD-WRT, but just use another one as an example, and modify it to do the start, stop, restart, etc. of mjproxy. Then in your MJ trunk, use the PIAF box as the host in the trunk setup and registration.
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Post by cohomology »

oldtimercurt

The search function here does not like me very much either:(

I'm just trying to use MJMD5 w/o a router, hehe.

C
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Post by cohomology »

Gr8! This is exactly what I'm looking for!
jaybob413 wrote:
cohomology wrote:Thank you jaybob413 for the instruction.

Seems your solution needs MJMD5 to run on a router. What if the PBX box is not behind a router? In fact, my scenario is that I'm running a hosted PBX virtual server.

So I gather my question boils down to: is there an MJMD5 port to i386 platform?
I compiled the mjproxy source and am running it on the PIAF box. I did run it on a router at one time, but have since moved it to the same box that Asterisk is running on. The router is just redirecting the IAX, SIP, and RTP UDP ports to the PIAF box which allows me to use the public ip address of the router to accept SIP URI addresses to connect.

If you search for mjproxy, you should be able to download the source, compile it, and set up run scripts to start it on boot. They are different that the ones that are posted for OpenWRT/DD-WRT, but just use another one as an example, and modify it to do the start, stop, restart, etc. of mjproxy. Then in your MJ trunk, use the PIAF box as the host in the trunk setup and registration.
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Post by cohomology »

Can anyone direct me to the source code of MJMD5? I just cannnot find it anywhere. Maybe I'm too blind to see it ... ...
jaybob413 wrote:
cohomology wrote:Thank you jaybob413 for the instruction.

Seems your solution needs MJMD5 to run on a router. What if the PBX box is not behind a router? In fact, my scenario is that I'm running a hosted PBX virtual server.

So I gather my question boils down to: is there an MJMD5 port to i386 platform?
I compiled the mjproxy source and am running it on the PIAF box. I did run it on a router at one time, but have since moved it to the same box that Asterisk is running on. The router is just redirecting the IAX, SIP, and RTP UDP ports to the PIAF box which allows me to use the public ip address of the router to accept SIP URI addresses to connect.

If you search for mjproxy, you should be able to download the source, compile it, and set up run scripts to start it on boot. They are different that the ones that are posted for OpenWRT/DD-WRT, but just use another one as an example, and modify it to do the start, stop, restart, etc. of mjproxy. Then in your MJ trunk, use the PIAF box as the host in the trunk setup and registration.
jaybob413
MagicJack Newbie
Posts: 6
Joined: Mon Mar 23, 2009 9:30 am

Post by jaybob413 »

cohomology wrote:Can anyone direct me to the source code of MJMD5? I just cannnot find it anywhere. Maybe I'm too blind to see it ... ...
Here is the post that I used for the source.

http://www.phoneservicesupport.com/post42750.html#42750

Compile and put the binary in /usr/sbin, then create a run script in /etc/init.d like:
(Be sure to change where it has YOURCITY and YOURPASSWORD)

--- begin script ---
#!/bin/bash
#
# mjproxy This shell script takes care of starting and stopping
# standalone mjproxy.
#
# chkconfig: - 60 50
# description: mjproxy is a sip proxy, which is the program \
# that forwards incoming requests for MagicJack.
# processname: mjproxy

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/sbin/mjproxy ] || exit 0

RETVAL=0
prog="mjproxy"
mjproxy="/usr/sbin/mjproxy"
MJPROXYARGS="0.0.0.0 5070 proxy01.YOURCITY.talk4free.com 5070 YOURPASSWORD"

start() {
# Start daemons.

echo -n $"Starting $prog: "
daemon $mjproxy $MJPROXYARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL
--- end script ---

Then add it to the startup list

chkconfig --add mjproxy

You will get a [Failed] on the start because the fork in mjproxy.c exits with a return value of 1, so it always says it fails. I did not bother with this, as the start, stop, restart, and status functions all do work. If you change the code at line 69 from exit(1) to exit(0) and recompile, start will always say [OK].

I did not spend any more time with that, as I was eager to move on to Google Voice integration.

And you may also want to change the useragent string that Asterisk sends to whatever the current MagicJack useragent string is. This can be done in /etc/asterisk/sip_general_custom.conf. Just add a line like:

useragent="MagicJack/1.80.484a (SJ Labs)"

That should do it. This setup has been working without fail or need to restart for days for both incoming and outgoing calls.
cohomology
MagicJack Newbie
Posts: 6
Joined: Thu May 21, 2009 10:24 am

Post by cohomology »

Thanks a lot! Will try it over the weekend and report back.

C
jaybob413 wrote:
cohomology wrote:Can anyone direct me to the source code of MJMD5? I just cannnot find it anywhere. Maybe I'm too blind to see it ... ...
Here is the post that I used for the source.

http://www.phoneservicesupport.com/post42750.html#42750

Compile and put the binary in /usr/sbin, then create a run script in /etc/init.d like:
(Be sure to change where it has YOURCITY and YOURPASSWORD)

--- begin script ---
#!/bin/bash
#
# mjproxy This shell script takes care of starting and stopping
# standalone mjproxy.
#
# chkconfig: - 60 50
# description: mjproxy is a sip proxy, which is the program \
# that forwards incoming requests for MagicJack.
# processname: mjproxy

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/sbin/mjproxy ] || exit 0

RETVAL=0
prog="mjproxy"
mjproxy="/usr/sbin/mjproxy"
MJPROXYARGS="0.0.0.0 5070 proxy01.YOURCITY.talk4free.com 5070 YOURPASSWORD"

start() {
# Start daemons.

echo -n $"Starting $prog: "
daemon $mjproxy $MJPROXYARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL
--- end script ---

Then add it to the startup list

chkconfig --add mjproxy

You will get a [Failed] on the start because the fork in mjproxy.c exits with a return value of 1, so it always says it fails. I did not bother with this, as the start, stop, restart, and status functions all do work. If you change the code at line 69 from exit(1) to exit(0) and recompile, start will always say [OK].

I did not spend any more time with that, as I was eager to move on to Google Voice integration.

And you may also want to change the useragent string that Asterisk sends to whatever the current MagicJack useragent string is. This can be done in /etc/asterisk/sip_general_custom.conf. Just add a line like:

useragent="MagicJack/1.80.484a (SJ Labs)"

That should do it. This setup has been working without fail or need to restart for days for both incoming and outgoing calls.
XoDiViAoX
magicJack Apprentice
Posts: 17
Joined: Fri Dec 07, 2007 7:02 pm

Post by XoDiViAoX »

Running Trixbox here
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

jaybob413 wrote:I am currently running PIAF with MagicJack. You will need the mjproxy daemon running somewhere to do the nonce twirling.


1) Using FreePBX, Set up a trunk for your MJ.


Trunk Name: MagicJack
PEER Details:
username=ENXXNXXXXXX01
type=friend
secret=MJ20CHARACTERPASSWRD
qualify=2000
port=5070
nat=yes
insecure=very
host=MJPROXYIP
fromuser=ENXXNXXXXXX01
dtmfmode=inband
context=from-trunk


Register String
ENXXNXXXXXX01:MJ20CHARACTERPASSWRD@MJPROXYIP:5070/NXXNXXXXXX


2) Create an Outbound Route to call out on. I set my Dial Pattern so dialing 8 uses MagicJack, 9 uses GV, etc. Pick whatever you want here.

Outbound Route
Dial Patterns
8|.
Trunk Sequence
SIP/MagicJack


3) Configure Inbound Routing
Inbound Route
DID Number: NXXNXXXXXX

Hope this helps.
On the inbound routing for mine I had to use the ENXXNXXXXXX01 for the DID number - otherwise I got number is not in service
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

XoDiViAoX wrote:Running Trixbox here
you will either have to download and patch the source then compile or use the mjproxy program and run it on your server. I just patched my home box and it works great, will patch and change the work box from the mjproxy program tomorrow after my days off.

Best bet is to move to PBXIAF like I did from TrixBox - too many things you can not modify in TB that are easily available for PBXIAF users....

Take a look, you wont regret it

Myk
kidjake28
MagicJack Newbie
Posts: 1
Joined: Wed Mar 18, 2009 1:18 am

Post by kidjake28 »

Need some help here please.

I have compiled the application on my trixbox server and put the startup script in the init.d directory as instructed.

All works fine accept when I try to telnet to port 5070 on the local host I get Unable to connect to remote host: Connection refused

What could be wrong?

This is my MJProxyargs

MJPROXYARGS="0.0.0.0 5070 proxy01.miami.talk4free.com 5070 PASSWORD"
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

I think it is easier to just patch asterisk chan_sip.c than to use the proxy if your running asterisk. An advantage is that you don't need a seperate proxy for each MJ trunk.

See the following thread for instructions: http://www.phoneservicesupport.com/magi ... t7243.html
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
pvsoares
MagicJack Newbie
Posts: 8
Joined: Wed Apr 17, 2013 3:17 pm

Magicjack plus write settings to my FreepBX server

Post by pvsoares »

has anyone find out how to get into the MJ Device to change the settings to the freepbx
crackerjack
Dan Should Pay Me
Posts: 784
Joined: Fri Nov 16, 2007 9:32 pm

Re: Magicjack plus write settings to my FreepBX server

Post by crackerjack »

pvsoares wrote:has anyone find out how to get into the MJ Device to change the settings to the freepbx
Yes, back in 2008
Good Luck

CrackerJack

MagicJack Customer #73
MagicJack user since May 2007
MagicJack abuser since June 2007
"I gots mo' numbers than a Lotto machine!!!"
Post Reply