Page 1 of 1

Reboot phone using Notify

Posted: Thu Dec 22, 2016 1:18 am
by VoIPTools
Here is the wireshark output of the reboot command that works when issued from my PBX. I would like to duplicate this in an external program. Note that is the phone and is the PBX. Can someone help me with the code needed in C#?

Request-Line: NOTIFY sip:101@ SIP/2.0
Method: NOTIFY
Request-URI: sip:101@
[Resent Packet: False]

Message Header
Via: SIP/2.0/UDP;rport
Max-Forwards: 70
Contact: <sip:101@>
To: <sip:101@>
From: <sip:101@>;tag=b85d0108
Supported: replaces
User-Agent: 3CXPhoneSystem 14.0.48169.513 (48654)
Event: check-sync;reboot=true
Content-Length: 0

A couple of things that I found curious (I'm new to SIP). In the message header the "To" and "From" are both using the IP of the PBX, while in the Request-Line it uses the IP of the phone. Also, the Message Header references port 5060, while the Request-Line uses 5062. I don't know if any of the hieroglyphics represents authentication information, but if that is needed, please offer guidance there as well.

Finally, I assume if I set reboot=false, the phone will auto-provision without a reboot. Is that true, or do I need a different command?

Re: Reboot phone using Notify

Posted: Thu Dec 22, 2016 5:11 am
by Aaron
Did my stack overflow answer get you close

If you have that phone registered with the sipsorcery server you can email me ( the public socket for it an I'll try sending it the NOTIFY request.

Re: Reboot phone using Notify

Posted: Fri Dec 23, 2016 1:59 pm
by VoIPTools
Aaron, it got me really close, which is why I posted the pcap example. It sends the notify, but the port numbers were backwards. Where my pcap has port 5060 I got 5061, and where the pcap had 5062 I got 5060. And I don't understand why my PBX has the IP of the PBX in both the from and to. But this is what I need to match apparently to get this to work. I can't find a syntax reference, so I don't know where to begin to adjust your code. The other issue is it hangs on waitone which I assume it's waiting for a valid response from the phone?

Your help is greatly appreciated.

Re: Reboot phone using Notify

Posted: Fri Jan 06, 2017 11:03 pm
by Aaron
I suspect the main thing you're missing is the Event header which is what's asking the phone to reboot "Event: check-sync;reboot=true", I've added it to the sample below. Note in the code below you may need to change the IP addresses and ports used in the SIP URIs.

Code: Select all

using System;
using System.Net;
using System.Threading;
using SIPSorcery.SIP;
using SIPSorcery.SIP.App;
using SIPSorcery.Sys;
using SIPSorcery.Sys.Net;

namespace SipSendNotify
    class Program
        private const int _defaultSIPUdpPort = SIPConstants.DEFAULT_SIP_PORT;             // The default UDP SIP port.
        private static SIPTransport _sipTransport;

        static void Main(string[] args)
                // Configure the SIP transport layer.
                _sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine());

                // Use default options to set up a SIP channel.
                var localIP = LocalIPConfig.GetDefaultIPv4Address(); // Set this manually if needed.
                int port = FreePort.FindNextAvailableUDPPort(_defaultSIPUdpPort);
                var sipChannel = new SIPUDPChannel(new IPEndPoint(localIP, port));

                SIPCallDescriptor callDescriptor = new SIPCallDescriptor("username", null, "sip:101@", "sip:101@", null, null, "Event: check-sync;reboot=true", null, SIPCallDirection.Out, null, null, null);
                SIPNonInviteClientUserAgent notifyUac = new SIPNonInviteClientUserAgent(_sipTransport, null, callDescriptor, null, null, (monitorEvent) => { Console.WriteLine("Debug: " + monitorEvent.Message); });
                notifyUac.ResponseReceived += (resp) => { Console.WriteLine(resp.ToString()); };


                ManualResetEvent mre = new ManualResetEvent(false);
            catch (Exception excp)
                Console.WriteLine("Exception Main. " + excp);
                Console.WriteLine("Press any key to exit...");

Re: Reboot phone using Notify

Posted: Sat Jan 07, 2017 4:12 pm
by VoIPTools
I eventually got my command to look EXACTLY like the command the PBX sends, yet it still doesn't work. I now wonder if there is some kind of authentication that takes place prior to sending the Notify? i ended up using the .Net UDP protocol library to send the command. I suppose it is time to start reading a SIP reference.

Re: Reboot phone using Notify

Posted: Tue Jan 10, 2017 7:12 am
by Aaron
If the authentication was in the NOTIFY request then you'd see a corresponding header. More than likely the phone only accepts the reboot NOTIFY requests from a server it has a current registration with (SIP REGISTER request).