Closed marknelissen closed 8 years ago
Hi Mark,
long story short - there is no reliable way to get an instant notice that a connection was broken.
I mean, in general there is no way one can reliably tell whether the connection persists with ms precision, especially within wireless networks.
Long story:
So having that in mind I decided to check several theories:
So I setup a VM with a FreeSwitch server to connect to and performed tests using the pjsip4net.Console app that comes with a source code. That's what I found:
Nevertheless, there are options:
2016-02-13 23:54:17,478 [11] DEBUG - 23:54:17.472 tcps0921AE64 TCP transport destroyed with reason 70016: End of file (PJ_EEOF)
. And this is how you can handle it: https://gist.github.com/siniypin/a20f0cf37bfb7cbc24b9. I know it is hackish at best, but this is the best you can get if you are required to diagnose disconnects almost instantly. P.S. I shall encapsulate this logic within 1.4 version wrapper shortly, for everybody to take advantage of fast feedback with TCP transport. Mind it isn't real-time anyways.
P.P.S. You also asked whether library automatically reconnects whenever it looses a connection - it doesn't. Newer versions of pjsip do. So having a wrapper on top of the latest version of pjsip would solve that issue for you. Otherwise you have to do it on your own.
Reconnecting means recovery from a disconnect. Pjsip periodically refresh registration with healthy connection, so you don't have to worry about that.
Hi,
Thank you very much for the detailed and in-depth explanation, as well as the time you are pouring into this.
I don't need ms precision, it is sufficient to know when the registration is not renewed, because of some error. However, it is not very clear to me which callback I should be registering on the wrapper to trigger another registration attempt manually. I did try some stuff, but I ended up triggering a new registration attempt, while the first was still busy. I did this by monitoring the state of the wrapper, which seems to not be the correct way of doing it, because it does not show when the registration is still trying, or else I checked the wrong state.
The use case I'm covering, is that the sip module is only part of a larger application on a public station. As such, the global application should not have to be restarted to recover from connection issues, since the end user will not have sufficient control to perform this operation. I want to put some watch dog function that automatically triggers reconnection (through registering again) in case the registration expires and fails to renew.
Also, are there any plans of upgrading the wrapper to the newer version of pjsip? Is the API much different? I barely understand how the current wrapper works, thus preventing me from offering you a pull request with the upgrade, at least right now.
Hi,
it looks like a simple AccountStateChanged
(https://github.com/siniypin/pjsip4net/blob/master/pjsip4net/Interfaces/IAccountManager.cs#L17) notification would be sufficient in your case. Objects of AccountStateChangedEventArgs
class have a StatusCode
property where values >= 400 mean something gone wrong.
Unfortunately, I have no time to add support for any newer versions of pjsip.
Cheers
Hi Mark, did that work out for you?
Hi,
I haven't had time to work on the project again, but I will soon test it. I'll keep you informed of the result.
Hi,
I've finally gone for the solution to upgrade to the newer version 2.4.5 of pjsip, using the pjsua swig interface. The library is handling the reconnection quite nicely. The documentation is complete, but there are some stuff you need to manually do, which should for me be handled by the wrapper. As such, your wrapper would still offer added value on top of this interface. I hope you get around one day to upgrade the wrapper to support the newer version of pjsip.
Thank you for all the time you spend helping me.
Hey Mark, good news.
I'd appreciate you sharing your SWIG bindings to pjsip, so anyone (including me) could simply adapt pjsip4net interface to pjsip 2.x.
Cheers
I've followed the instructions of MikeGawi on issue 15. Although pjsip natively only has the necessary configurations for java and python, there is only minor adaptation to be done of the generated files.
I only discovered the project at https://github.com/StrikeForceZero/PJSip-CSharp after having done all the work. I don't know how far along it is, and whether it works.
pjsua2api.zip contains the swig bindings I used. The documentation at www.pjsip.org/docs/book-latest/html/index.html is rather helpful on how to use the api, even though you have to translate the example code from c++ to c#.
Awesome, Mark. Thank you very much! ᐧ
Best regards, Boris Tveritnev de.linkedin.com/pub/boris-tveritnev/11/3a4/113/ www.xing.com/profile/Boris_Tveritnev
On 16 March 2016 at 12:53, marknelissen notifications@github.com wrote:
pjsua2api.zip https://github.com/siniypin/pjsip4net/files/175879/pjsua2api.zip contains the swig bindings I used. The documentation at www.pjsip.org/docs/book-latest/html/index.html is rather helpful on how to use the api, even though you have to translate the example code from c++ to c#.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/siniypin/pjsip4net/issues/43#issuecomment-197281369
Hi,
Is there some kind of failover included in the library in case the connection and/or registration fails? Does the library retry to connect/register, or does this need to be piloted externally? If so, how is the best way to interact with the cycle to renew the connection/registration?
What happens on connection interruption? Does the library reconnect automatically on connection loss to the sip server? How to detect this, and fix it manually, if it does not?
I'm talking about the connection to the sip server, not to another sip client.
Regards,
Mark Nelissen