Asterisk notifications (solved)

Discussions about using SIP Sorcery on your own computer/server
Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications

Post by Nebukadnezar » Thu Sep 30, 2010 11:35 am

I have removed all <MonitorLoopbackPort value="10001"/> lines from sipsorcery-appsvr.exe.config.
restored the one under <sipmonitor> because it gave errors (SIPMonitorMediator)

SIPMonitorClientManager also created a default udpClient() with a random port, so i gave that port 9050 to be able to account for it.
SIPRegistrarDaemon also created a default udpClient() with a random port, so i gave that port 9051 to be able to account for it.

These were the first messages after the server was started (last line of startup: SIPProxyDaemon STUN client started.):

Transaction already exists, ignoring duplicate request, REGISTER sip:192.168.0.5:5060;transport=UDP.
Transaction already exists, ignoring duplicate request, REGISTER sip:192.168.0.5:5060;transport=UDP.
Transaction already exists, ignoring duplicate request, REGISTER sip:192.168.0.5:5060;transport=UDP.

and a new zombie port was born:

sipsorcery-appsvr.exe:2676 UDP 0.0.0.0:1762 *:*

and after some DNS activity:

sipsorcery-appsvr.exe:2676 UDP 0.0.0.0:1762 *:*
sipsorcery-appsvr.exe:2676 UDP 0.0.0.0:1765 *:*

the search continues

(WatchTowerDaemon.cs also instantiated SIPMonitorEventWriter, but is not started)

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Thu Sep 30, 2010 5:22 pm

Server is now running for a couple of hours and no unidentified ports. Very happy with these results. Time to start documenting the changes.

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Tue Oct 05, 2010 7:14 pm

Perhaps it would be better to open a new thread, but since this is related to the unaccounted UDP ports, I will keep it here.

I noticed that when the STUN server of my provider does not responds within 3 seconds, a null is returned. SIPProxyDaemon starts the STUNClient thread and the SIPProxyCore, while STUN_CLIENT_THREAD_NAME places (m_statelessProxyCore.PublicIPAddress = null).

This happened 15 times overnight and resulted in 15 unaccounted UDP ports on the EXE.
(I changed Stun timeout to 10sec, and inserted GotRequest/GotResponse debug messages in the SIPProxyCore)

Code: Select all

2010-10-05 21:19:29,534 [sipproxy-stunclient] ERROR sipsorcery [(null)] - STUNClient server response timedout after 10s.
2010-10-05 21:19:39,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:40,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:41,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:42,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:43,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:44,596 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:45,595 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:55,595 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:56,595 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:57,595 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:58,594 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:19:59,594 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:00,594 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:01,594 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:05,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:06,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:06,281 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:07,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:07,281 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:08,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:08,297 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:09,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:09,281 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:10,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:10,281 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:11,078 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:11,281 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:11,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:12,297 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:13,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:14,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:15,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:16,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:17,593 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:22,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:23,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:24,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:25,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:26,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:26,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:27,077 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:27,280 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:27,592 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:28,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:20:29,280 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:39,555 [sipproxy-stunclient] ERROR sipsorcery [(null)] - STUNClient server response timedout after 10s.
2010-10-05 21:21:39,727 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:40,227 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:41,243 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:43,243 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:47,258 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:51,273 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:55,273 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:21:59,288 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:03,304 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:07,303 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:11,319 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:21,740 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:22,240 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:23,255 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:25,271 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:29,270 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:29,723 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:30,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:30,723 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:31,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:31,723 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:32,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:32,739 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:33,301 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:33,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:33,723 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:34,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:34,723 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:35,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:35,739 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:36,395 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:37,176 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:37,301 [sipchanneludp-3783] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:38,176 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 21:22:39,176 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:38:53,359 [sipproxy-stunclient] ERROR sipsorcery [(null)] - STUNClient server response timedout after 10s.
2010-10-05 22:39:13,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:14,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:14,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:15,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:15,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:16,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:16,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:17,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:17,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:18,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:18,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:19,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:19,358 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:20,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:30,295 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:31,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:32,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:33,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:33,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:34,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:34,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:35,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:35,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:36,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:36,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:37,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:39,357 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:45,137 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:46,137 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:46,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:47,137 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:47,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:48,137 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:48,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:49,153 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:49,294 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:50,137 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:50,293 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:51,153 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:51,293 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:52,309 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
2010-10-05 22:39:53,356 [sipchanneludp-4966] ERROR sipproxy [(null)] - Exception SIPProxyCore GotRequest. Object reference not set to an instance of an object.
I don't know how all this works, but I am leaning. Perhaps it is a good idea to add a list with alternative STUN server to STUNClient so it can choose another when one fails.

Edit: I inserted an array with additional STUN servers and let it 'foreach' through it; that works for the moment.

Code: Select all

        public static string[] STUNServers = new string[5]
            { "stun.voipplanet.nl",
              "stun01.sipphone.com",
              "stunserver.org",
              "stun.voxalot.com.au",
              "stun.xten.com" };

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Asterisk notifications (solved)

Post by Aaron » Wed Oct 06, 2010 9:50 am

That's a weakness in the software alright, thanks for troubleshooting it. I'd never come across that problem as I haven't noticed the STUN server I use with my local instance timeout and the main sipsorcery.com service is on a public IP address so doesn't use the STUN client.

It sounds like the orphaned UDP ports must be getting created in SIPSorcery.Net/STUN/STUNClient.cs. Putting the creation of the UDPClient into a using block to make sure the socket is cleaned up irrespective of whether it encounters and error or not should fix it.

Replace

Code: Select all

UdpClient udpClient = new UdpClient(stunServer, m_defaultSTUNPort)
with

Code: Select all

using (UdpClient udpClient = new UdpClient(stunServer, m_defaultSTUNPort))
{
 ...
}

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Wed Oct 06, 2010 11:51 am

Thanks, Aaron. I was not aware of that 'using' statement, but I am 'using' it now.

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using SIPSorcery.Sys;
using log4net;

namespace SIPSorcery.Net
{
    public class STUNClient
    {
        private const int STUN_SERVER_RESPONSE_TIMEOUT = 3;

        private static ILog logger = AppState.logger;

        private static readonly int m_defaultSTUNPort = STUNAppState.DEFAULT_STUN_PORT;

        public static string[] STUNServers = new string[5]
            { "stun.voipplanet.nl",
              "stun01.sipphone.com",
              "stunserver.org",
              "stun.voxalot.com.au",
              "stun.xten.com" };

        public static IPAddress GetPublicIPAddress(string stunServer) {
            foreach (string STUNServer in STUNServers) 
            {
                try 
                {
                    using (UdpClient udpClient = new UdpClient(STUNServer, m_defaultSTUNPort)) 
                    {
                        logger.Debug("STUNClient attempting to determine public IP from " + STUNServer + ".");
                        STUNMessage initMessage = new STUNMessage(STUNMessageTypesEnum.BindingRequest);
                        byte[] stunMessageBytes = initMessage.ToByteBuffer();
                        udpClient.Send(stunMessageBytes, stunMessageBytes.Length);

                        IPAddress publicIPAddress = null;
                        ManualResetEvent gotResponseMRE = new ManualResetEvent(false);

                         udpClient.BeginReceive((ar) => {          
                            IPEndPoint stunResponseEndPoint = null;
                            byte[] stunResponseBuffer = udpClient.EndReceive(ar, ref stunResponseEndPoint);

                            if (stunResponseBuffer != null && stunResponseBuffer.Length > 0) {
                                logger.Debug("STUNClient Response to initial STUN message received from " + stunResponseEndPoint + ".");
                                STUNMessage stunResponse = STUNMessage.ParseSTUNMessage(stunResponseBuffer, stunResponseBuffer.Length);

                                if (stunResponse.Attributes.Count > 0) {
                                    foreach (STUNAttribute stunAttribute in stunResponse.Attributes) {
                                        if (stunAttribute.AttributeType == STUNAttributeTypesEnum.MappedAddress) {
                                             publicIPAddress = ((STUNAddressAttribute)stunAttribute).Address;
                                             logger.Debug("STUNClient Public IP=" +  publicIPAddress.ToString() + ".");
                                        }
                                    }
                                }
                            }
 
                             gotResponseMRE.Set();
                        }, null);

                        if(gotResponseMRE.WaitOne(STUN_SERVER_RESPONSE_TIMEOUT * 1000)) {
                            return publicIPAddress;
                        }
                        else {
                            logger.Warn("STUNClient server response timedout after " + STUN_SERVER_RESPONSE_TIMEOUT + "s.");
                            //return null;
                        }
                    }
                }
                catch (Exception excp) {
                    logger.Error("Exception STUNClient GetPublicIPAddress. " + excp.Message);
                    throw;
                }
            }
            logger.Error("None of the STUN servers responded");
            return null;
        }
    }
}
Chance that 5 stun servers will fail is very slim (or no Internet connectivity).

Edit: Oops.. got this one:

Code: Select all

Unhandled Exception: 
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.UdpClient'.
   at System.Net.Sockets.UdpClient.EndReceive(IAsyncResult asyncResult, IPEndPoint& remoteEP)
   at SIPSorcery.Net.STUNClient.<>c__DisplayClass3.<GetPublicIPAddress>b__0(IAsyncResult ar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.CompleteCallback(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
This seems to occur when the udpClient had been setup and during the communication with the specific STUN server (stun.voipplanet.nl) the STUN server goes down, so some additional error handling is required (working on that).

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Fri Oct 22, 2010 7:22 am

Aaron,

I have been struggling with these STUN client crashes for over a week now. I rewrote the whole thing (firstly, because I could not cope with that ‘lambda’ syntax you are using so intense (I’m still a novice) and secondly to create more room for TRY and CATCH phrases). I rewrote it first using the UdpClient class and when that failed, I rewrote it using Sockets. Still I got the same (unpredictable) results. As a means to get more time to analyze this problem, I dropped the STUN client and replaced it with a DYNDNS request, and update, module; that works well.
The recurring problems were:

- “Cannot access a disposed object.”
- “The IAsyncResult object was not returned from the corresponding asynchronous method on this class.”
- “An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full”

The server could run for hours without a single error, or an error occurred within seconds after starting it. At each time an error occurred my firewall log showed an ‘ICMP unreachable error’.
After searching a lot, I found next info: ((main) source: Aaron Zupancic)

Code: Select all

Hm... apparently, if you do a Send, and get the "ICMP port unreachable" response, this manifests itself as an error on the next Receive you try to do on the same socket.  MSDN claims that a socket
is unusable once that happens, so you may have to recreate it entirely on the same endpoint (once the client goes back online, it shouldn't make any difference anyway, so long as the endpoint is the same).


Lately, I've been debugging an issue in an application that I wrote that was a bit frustrating, though until today I've pretty much ignored the error.  I decided to bite the bullet and dig in and 
try to figure out the problem. I have an application that creates some datagram (UDP) endpoints using the Socket class found within the System.Net.Sockets namespace.  As it turned out, there were 
times during my application's execution path in which the sockets would suddenly stop responding, though the port was still open (this could be ascertained via netstat or TCPView).  
To make the situation more perplexing, I had another application that used the exact same objects and it didn't exhibit the same behaviors - it continued to run as expected.

So I dug in a bit and within about 30 seconds figured out the problem - at least what was causing the problem:  the point at which the application always had this problem of stopping to respond it 
would always send a datagram packet to localhost (127.0.0.1) to determine if it could find a particular listener/host.  Well, if I had a listener at localhost there was never a problem, but if no 
socket was bound to that endpoint my UDP socket would throw a SocketException during the EndReceiveFrom().

I put together some tests and found that the WinSock error being thrown was WSAECONNRESET; in other words the socket was forcibly closed by the remote host.  This was disconcerting for a little while, 
but I found that if I simply called BeginReceiveFrom() again, it would be up and running - but this wasn't necessarily the right fix.

Microsoft made some changes to their WinSock implementation between Windows NT 4.0 and Windows 2000.  One of these was that the Recvfrom() function would return WSAECONNRESET instead of continuing 
to block or time out if the sendto() function resulted in an “ICMP port unreachable”.  In other words, if you sent a datagram to a listening port all was cosher and behaved normally, however, 
if you attempted to send a datagram to an endpoint without a listening application, a pending/blocking call to Recvfrom() would throw.  Previously, my SocketException handling code would simply 
return without attempting to re-listen, assuming that if the error were received the socket was closing down.

It is possible, fortunately, to achieve Windows NT 4.0 behavior rather than having the socket return an error result.  This is accomplished by calling the WSAIoctl() function in Ws2_32.dll.  
Well, if you're writing code using the .NET framework, it's not necessary to dip down into P/Invoke to call the function, but rather you can use the IOControl() method on the Socket class.  
The key lies in passing in the control code of SIO_UDP_CONNRESET and a value of False (0) to turn off the 'new', Windows 2000 behavior - thus restoring the expected Windows NT 4.0 behavior.

const uint SIO_UDP_CONNRESET = 0x9800000C;

It's interesting, and I feel unfortunate, that the IOControl() function accepts control codes of type Int32.  Many of the control codes are UInt32 values.  So instead of taking the default value 
for SIO_UDP_CONNRESET and passing that in (which we can't because it's out of the range for an Int32), we must take the same value and convert it to a signed value.

// 0x9800000C == 2440136844 (uint) == -1744830452 (int) == 0x9800000C
const int SIO_UDP_CONNRESET = -1744830452;
byte[] inValue = new byte[] { 0, 0, 0, 0 };     // == false
byte[] outValue = new byte[] { 0, 0, 0, 0 };    // initialize to 0
_socket.IOControl(SIO_UDP_CONNRESET, inValue, outValue);

Simply make that call during the initialization of the socket and the WSAECONNRESET error will not be raised when a datagram is sent to a closed/invalid end point.

Happy coding!

.NET 
Saturday, February 19, 2005 5:22:00 PM (Mountain Standard 

// 0x9800000C == 2440136844 (uint) == -1744830452 (int) == 0x9800000C
const int SIO_UDP_CONNRESET = -1744830452;
byte[] inValue = new byte[] { 0, 0, 0, 0 };     // == false
byte[] outValue = new byte[] { 0, 0, 0, 0 };    // initialize to 0
_socket.IOControl(SIO_UDP_CONNRESET, inValue, outValue);


uint IOC_IN = 0x80000000;
uint IOC_VENDOR = 0x18000000;
uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;

s.IOControl((int)SIO_UDP_CONNRESET, new byte[] {Convert.ToByte(false)}, null);

Zupancic was just telling us that it is kind of lame to copy and paste
code snippets from anywhere without giving them a serious thought first.

So after being lame for a few hours (give or take a few more hours), I
finally gave some thought to it and luckily managed to solve the problem:
instead of
// 0x9800000C == 2440136844 (uint) == -174483042 (int) == 0x9800000C
we need
// 0x9800000C == 2550136844 (uint) == -1744830452 (int) == 0x9800000C

so this snippet seems to work:

const int SIO_UDP_CONNRESET = -1744830452;
byte[] inValue = new byte[] { 0, 0, 0, 0 }; // == false
byte[] outValue = new byte[] { 0, 0, 0, 0 }; // initialize to 0
_socket.IOControl(SIO_UDP_CONNRESET, inValue, outValue); 

did not try it, but it should work

const long IOC_IN = 0x80000000;
const long IOC_VENDOR = 0x18000000;
const long SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;

byte[] optionInValue = { Convert.ToByte(true) };
byte[] optionOutValue;

Socket.IOControl(SIO_UDP_CONNRESET, optionInValue, optionOutValue);


******************************************************************************************************************
I'm writing some UDP client/server code in C#.

As UDP is "connectionless", I was surprised to see this error: "An existing connection was forcibly closed by the remote host". This exception occurs when I call ReceiveFrom() any time after a client 
quits without doing the normal clean-up (closing its socket). The number of exceptions cumulates with the number of clients 
that exit that way.

There are two major problems:

1. The exception repeats at every ReceiveFrom call, even if I catch it.
2. I don't know any way to see the remote address that is causing the problem, as the endpoint comes back as zeros.

I can avoid the problem by using an obscure IOControl call, but I'd like to know what's going on. Why is the exception repeating and how am I supposed to handle it? Is there any way to get the remote 
IP address that is causing the problem? 

After more reading and runningtests, this is my conclusion:

I'd like to note that the WSARecvFrom documentation seems to suggest that closing the port would be the procedure for TCP connections and not UDP. It should also be noted that an ICMP Port Unreachable 
response will normally have the originating IP address, so the application can identify the lost 'connection'.

How to handle the error:

Option 1: Ignore the messagesby setting SIO_UDP_CONNRESET to false. (Documented, as you pointed out, underWSAIoctl)
Option 2: Process the ICMP message and 'disconnect' the remote host.

I believe it's possible that the ICMP message might not arrive under certain circumstances. Either way, the server should monitor clients and stop sending to them when the connection stops responding.

Thanks for your reply. All the MSDN documentation refers to UDP/datagrams as "connectionless". I'm just using their terminology.

Semantics aside, when I call ReceiveFrom, I'm not specifying a client- just getting the next available datagram. So, as I've mentioned,I have no way of finding out where it came from.Howis the 
program supposed tohandlesuch anexception? I can't tell what client 'disconnected'. It also just repeats every time I call ReceiveFrom, even if I catch it. That doesn't stop incoming datagrams 
being processed from other clients, but the exception occurs every time.

The obscure IOControl call definitely avoids the problem. The thing is, I've had trouble finding adequate documentation on it. It's really frustrating.

Here it is:


uintIOC_IN=0x80000000;  
uintIOC_VENDOR=0x18000000;  
uintSIO_UDP_CONNRESET=IOC_IN|IOC_VENDOR|12;  
socket.IOControl((int)SIO_UDP_CONNRESET,newbyte[]{Convert.ToByte(false)  
},null);  

Well shoot... the whole thing just seems like a conundrum...

You're receiving data from unknown hosts as "connectionless".. BUT.. you're getting "connection" exceptions... because obviously a connect HAS to be made, we're just shielded or not aware of it... 
but then there's nothing you can do about the exception because you will continue to receive data from these unknown hosts... unless you reset the connection... which is what the IOControll call 
is I'm assuming is doing.

Can I ask if the exception occurs intermittently, or somewhat predictable... and how intensive is this whole process... do you know/expect a large number of unknown clients? The reason I ask is 
because a while back, I dealt with my code that was not properly cleaning up after Sockets, which I know isn't the case here, but what it showed me was that I overloaded my machine so much that 
I could not connect to *anything* anymore... as if I flooded my machine with connections.

Take care.

Your speculation is correct.

According toWSARecvFrom on MSDN,WSAECONNRESET is a valid error code for UDP sockets, with this meaning:

For a UPD datagram socket, this error would indicate that a previous send operation resulted in an ICMP "Port Unreachable" message.

It also notes you should close the socket that errored (to clear the error). Your SIO_UDP_CONNRESET I/O Control call (documented in WSAIoctl on MSDN) changes this behavior so that it will not 
raise WSAECONNRESET.

If it were my code, I'd handle the exception by closing the socket. Note that other errors may cause exceptions from Socket.ReceiveFrom, such as a packet arriving with an expired TimeToLive field.
When working with sockets, expect every socket method to possibly throw an exception, and the general recovery should be to close and reopen the socket.

After more reading and running tests, this is my conclusion:

I'd like to note that theWSARecvFrom documentation seems to suggest that closing the port would be the procedure for TCP connections and not UDP. It should also be noted that an ICMP Port Unreachable 
response will normally have the originating IP address, so the application can identify the lost 'connection'.

How to handle the error:

Option 1: Ignore the messagesby setting SIO_UDP_CONNRESET to false. (Documented, as you pointed out,underWSAIoctl)

Option 2: Process the ICMP message and 'disconnect' the remote host.

I believe it's possible that the ICMP message might not arrive under certain circumstances. Either way, the servershould monitor clients and stop sending to them when the connection stops responding.

Cheers
Any application of the information above made no difference whatsoever, so I went back to the basics: Network connectivity; One port on my main router connected to a switch that connects to the DMZ, and that port was fixed at 100MB full duplex while the corresponding port on the switch was set to auto negotiate; hence all the ICMP trouble. After correcting that, I reverted to your original STUN client and the server is now up and running for three days without any issues.

(Yet another)One of life’s embarrassing moments……. (Nevertheless, I learned a lot!)

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Asterisk notifications (solved)

Post by Aaron » Fri Oct 22, 2010 11:38 am

Good to hear you had a learning experience and hopefully also solved the issue.

Just so I'm clear the STUNClient "crashing" was really just an exception being thrown which meant the sipsorcery server didn't know your public IP address for the 60s it took until it tried the STUN server again? The STUNClient definitely should not have been able to bring your sipsorcery process down.

Thanks for posting the exchange about the investigation into the UDP sockets. I'm not sure if some of those posts were yours or not but ICMP & UDP is something I have also investigated in the past. It would be very handy to be able to extract the source IP address from the ICMP messages so the sending socket would actually knwo to stop sending. With TCP it's easy enough but with UDP when you get an ICMP message the socket throws an exception but if the socket happens to be sending to lots of different endpoints, as the sipsorcery SIP sockets are, it's none the wiser about which remote socket resulted in the ICMP. I know the source IP address is in the ICMP messages because I can see it in the packet traces I was just never able to work out a convenient way to extract it with .Net http://stackoverflow.com/questions/6265 ... ckets-in-c. It doens't cause any issues it would just be an extra efficiency to avoid a few retransmits when a socket disappears for whatever reason.

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Fri Oct 22, 2010 3:34 pm

I have two 2003 servers in my DMZ segment, and one of them clearly receives the ICMP data with your code, so it would appear that the basic configuration of the server determines wether you can get the ICMP packets or not. I am working out the differences at this moment. The one that does receive them does not have network monitor tools installed, but I will post the results as soon the the other machine also is able to get those ICMP packets.

Code: Select all

ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 28 from 192.168.2.3:0
ICMPListener received 60 from 192.168.2.3:0
ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 29 from 127.0.0.1:0
ICMPListener received 28 from 192.168.2.3:0
ICMPListener received 60 from 192.168.2.3:0
ICMPListener received 28 from 110.12.93.34:0
Bah to me! Both work, I just needed to allow ICMP to pass through my firewall (ISA). I added a rule that allowed all ICMP to pass and sure enough if got echo requests, so now i adjusted that rule to only allow "destination unreachable" to allow checking the remote endpoint during an exception.

Slowly getting there:

Wireshark:

105 2010-10-24 12:47:17.763723 38.104.134.166 192.168.0.5 ICMP Destination unreachable (Network unreachable)

Raw ICMP socket:

ICMPListener received 56 from 38.104.134.166:0

To be continued

jvwelzen
Posts: 716
Joined: Thu Sep 11, 2008 1:56 pm

Re: Asterisk notifications (solved)

Post by jvwelzen » Sun Oct 24, 2010 4:51 pm

Would it not be easier to add a public ip address to the config file

I never have any problems with the SS server regarding STUN

Code: Select all

    <PublicIPAddress value="82.111.240.16" /> 
    <!--<STUNServerHostname value="stun.ekiga.net" />--> 

Nebukadnezar
Posts: 47
Joined: Tue Aug 10, 2010 1:46 pm

Re: Asterisk notifications (solved)

Post by Nebukadnezar » Mon Oct 25, 2010 7:35 am

Thanks for your suggestion; I do know I can set the public IP, but that is not the point. This is not only related to the STUNClient, but to the entire UdpClient class. The problems arise when a socket peer unexpectedly disconnects (or becomes unreachable due to network issues,) the forthcoming ICMP messages required to interpret the situation (mainly the IP number and Port of the remote host) seem to be suppressed somehow by Windows. At this moment, I have a situation, as described by Aaron, where the appropriate ICMP messages are visible in Wireshark, and on a raw socket reader, but no (ICMP) status information is available on the UdpClient (no SocketException). In a situation where the local socket peers with a single remote host, this is not a problem but when a single local socket is required to connect to multiple remote sockets, there is no way to establish (stateless) which remote host ‘unexpectedly’ has become unreachable.

To make things more complicated I received a couple of those ICMP replies through a proxy, meaning that a router somewhere in-between SipSorcery and the remote target host replies with an ICMP message “Destination unreachable” on behalf of the remote target host. This requires the ICMP message body (while for now the UdpClient is not even aware of any ICMP messages at all) needs to be interpreted to obtain the IP number and port of the remote target host. Moreover, if that is not enough to discourage a conundrum chaser like me, all this stuff is NAT’ed. Fortunately, there are some rules to that (RFC 5508); unfortunately, not all equipment (and software) follows those rules.

Currently I am working with a tandem setup with two sockets for a single connection (one raw, one UdpClient (or Socket)) to try to resolve this issue.

Sorry for the long reply, but it helps me to get a better view on what I am trying to accomplish.

Post Reply