RestComm / jain-sip

Disclaimer: This repository is a git-svn mirror of the project found at http://java.net/projects/jsip whose original repository is developed collaboratively by the Advanced Networking Technologies Division at the National Institute of Standards and Technology (NIST) - an agency of the United States Department of Commerce and by a community of individual and enterprise contributors. TeleStax, Inc. will perform some productization work, new features experimentation branches, etc for its TelScale jSIP product that doesn't concern the community from the main repository hence this git repository.
http://www.restcomm.com/
144 stars 152 forks source link

[Question] Android WiFi -> 3g #194

Closed ktiniatros closed 4 years ago

ktiniatros commented 4 years ago

On Android, when you switch from WiFi to 3g and vice versa, the tcp socket closes (which makes sense since you get a new ip address).

What's the proper way of handling this scenario with jain-sip? Should I restart the sipstack?

ktiniatros commented 4 years ago

I ended up to listen for ip changes (via the network monitor broadcast receiver) and when the current ip changes, then I recreate the listening point and the sip provider:

        sipManager.removeSipListener()
        getListeningPoints().forEach(sipStack::deleteListeningPoint)
        getSipProviders().forEach(sipStack::deleteSipProvider)
        val sipProfile = SipProfile(host)
        val listeningPoint = sipStack.createListeningPoint(sipProfile.getLocalIp(), sipProfile.getLocalPort(), sipProfile.getTransport())
        val sipProvider = sipStack.createSipProvider(listeningPoint)
        sipManager.updateSipProfile(sipProfile)
        sipManager.updateSipProvider(sipProvider)