Trivial SMTP ASP.NET Winsock Connectivity Issues

Posted on

ASP.NET C#Lately I have been experiencing issues with running SMTP on ASP.NET 1.1 on a Windows Server specifically the Standard edition. It was a trivial issue and very difficult to trace. The problem would appear in just a day and sometimes will disappear for weeks. The issue has been attributed to a Winsock crash (ASP.NET informs this through the error page). I have not found I have not found any blogs that tackle this issue so I hope this post will help others.

This issues are posted by me in StackOverflow and ServerFault :

The server specifications are below and my notes on the issue:

Windows Server Standard on SP2
IIS 7 with ASP.NET 1.1
IIS 6 for SMTP

The server hosts many websites running ASP.NET 1.1. These websites use the built in SMTP server on IIS6.

The SMTP works fine for a while but after a few weeks or months, It will stop sending emails. I tried sending one via Telnet it seems fine so the SMTP server is not the issue.

I tried restarting the Application Pools but it had not effect whatsoever. I also tried restarting IIS 7.0 and IIS 6.0 it still will not send messages.

The only temporary way we found to fix this was to restart the server.

Is there an ASP.NET cache that we can clear or is causing this issue?

UPDATE:

Got the fix!

It was a hunch but I restarted the Print Spooler and DNS Client services in the server and now emails are sent successfully.

But I still do now know why this happens for ASP.NET 1.1 projects.

UPDATE 2:

Issue appeared again today! I got lucky I thought I had to wait weeks to test it again.

I started by restarting the DNS Client service. No effect still cannot send emails. I then restarted the Print Spooler service and to my surprise it was the culprit! ?????????

How is this even, what, why? huh?

I disabled the Print Spooler permanently. Email still works. I do not think we print anything or if the Print Spooler does any other tasks other than printing.

If it does do anything please comment below.

UPDATE 3:

The fix was temporary. I found out today that WINSOCK refused connections from ASP.NET but accepted connections via telnet mail.

Still trying to find out why this is happening.

UPDATE 4:

Well finally made a reboot with the WINSOCK corruption fixes applied. Hope this holds forever and the bug does not reappear.

FINAL UPDATE:

After a few weeks of debugging and fix finding the only workaround for this would be to either reboot the server regularly, move to System.Net.Mail instead of System.Web.Mail or use Microsoft SQL Server DBMail.

MagicJack Installation, Firewall Setup and Port Settings

Posted on

UPDATED ON APRIL 7, 2011 Magic Jack, this amazing usb device will allow you to make unlimited calls to the US and Canda for $20.00 per year and better yet, you get a registered landline number that allows you to receive calls. I’ve found a lot of sites on how to set up routers, firewalls and access points to allow Magic Jack to pass through. None of them worked. It was agitating so I had to do some tests on my own. Read on for the complete port lists.

 

magic jack dongle

 

Magic Jack is very easy to install in the first place. Just plug it in and then plug your phone to it. The executable or installer should run automatically, if not open the flash drive, find it and then run it. The next part will deal with firewalls and port settings.

 

I used Active Ports to find out what ports MagicJack was using and it turns out that it uses a lot of UDP ports and two TCP ports. Their website specifically states that the device only uses UDP ports 5060-5070 (reference: LINK (removed) – GOOGLE’S WEB CACHE OF THE PAGE UPDATE April 7, 2011:The knowledge base has been down for a while but I managed to retrieve Google’s cache of the site.) which I found out was clearly not true. I found this out by performing calls to a random list of phone numbers (except 911 numbers ^_^). I dialed at least 40 phone numbers repeatedly. After this, I was able to conclude that MagicJack uses random UDP ports in the high range. UDP ports might seem a bit less important than TCP ports but as a Systems Administrator this will create a highly unsecured and exposed network. I was only able to achieve 100% connectivity with the 40 phone numbers after opening a range of UDP ports.

 

magicjack ethernet dongle

 

I also stumbled upon a lot of sites and forum posts that tell magic jack users to setup port forwarding, this is NOT true!

 

Below is the exact list of the TCP and UDP Ports that I had to open in my firewall and router (NOT port forward) to achieve 100% connectivity:

 

TCP Ports List: 80 (HTTP), 443 (HTTPS)

UDP Ports List: 5060, 5070, 10000-65535

 

It is really strange why the device was designed like this. My guess is that the device is intended solely for home use and not commercial use.