I know i've been asking a lot of questions lately..
But still, i have a problem that drives me crazy. The thing is, i have openfire with asterisk-im. and in asterisk-im i have added four asterisk server connections (ami port - 5038). two of these asterisk servers are within the same LAN as openfire/asterisk-im. and other two asterisk servers are in remote locations connected through VPN.
Now, everything is working, phone mappings, calls, etc..
But i have problem with presence and On The Phone status. Actually, everything is working fine with the two asterisk servers that are in the same LAN as openfire server.
But the other two, that are connecting through VPN to my oipenfire server are having problems - a user (from one the remote asterisk servers) that initiates a call goes On The Phone and stays stuck in this status forever. It goes again to Online only after asterisk-im has been restarted.
Now, can someone please provide a hint where i should search for a solution? is it some problem with NATing? i have all ports opened on these routes.. and still, i'm having the same problem.
How asterisk sends information about presence changes to Openfire? is it via AMI port (5038)?? if it is using the same port, how come it si able to send messages to initate a call and initiate On The Phone presence, but not able to send the signal that user has hang-up? or is it using some other port for the hang-up messages?
Also, i am even willing to forget abt On The Phone presence, if someone can tell me where in MysSQL db is that flag stored, and ill make a mysql script that shall set it to online every minute or so.. just to avoid all my remote users staying On The Phone 99% of time.
Thanks in advance!!!!
just to make it clear:
openfire - asterisk within the same LAN = everything is OK
openfire - asterisk through VPN = everything is OK except going back to Online once a call is terminated
ok, i guess this could be a monologue
I eventually solved the problem. Once i spent days eliminating all other possibilities (NAT complications, masquearding, bugs in Java, etc.) i was left with one single possible cause for this: latency
And it turned out that Asterisk's manager.conf has a parameter called writetimeout which "sets the timeout used by Asterisk when writing data to the AMI connection for this user" (in this case, this user is Openfire). By default, this value is 100ms which is usually enough when Openfire server is within the same LAN as Asterisk server. But for WAN and geographically distributed architectures, ping/latency is usually much more. I increased writetimeout from 100 to 1000 and it worked like a charm.
If it was only explicitly stated within manager.conf by default.. it could have saved me a lot of time. I would have seen it and experimented with its values. Anyway, that solves the problem.