SQL Server Express Edition and Dynamic Ports

by Jon Davis 17. May 2009 14:13

While transferring to my new web host, I ran into a roadblock that had me stalled for a day or two while I tried to figure out what was going wrong. I like to use my own laptop here at home when managing SQL stuff, so I poked a special hole in the Windows Firewall on my new VPS instance to just allow my IP on port 1433, while enabling TCP/IP for SQL Server and restarting the service. But I could not connect!

I spent several hours poking at it, rebooting it, turning off the Windows firewall completely (temporarily), trying to get connected to that darn SQL Server instance I had installed on my new VPS, but it just would not connect. Then I noticed that the client tools (namely SSMS) on the VPS itself could not connect to ITSELF on the TCP/IP stack, it could only connect on Shared Memory or Named Pipes. What is going on?!! Could it be a bad OS image on the VPS?

Eventually it got resolved. The VPS hosting company was very helpful in assisting me on the matter, and at the same time I got some replies on a SQLServerCentral.com forum post that narrowed down to the same problem: Dynamic Ports.

This SQLServerCentral.com forum reply was the critical new knowledge for this weekend.

Hello Jon,

SQL Server Express (2005 & 2008) defaults to Dynamic Ports, whereas the Default Instance of other Editions listen on Static Port 1433 (by default). 

Having a Zero in the Dynamic Port configuration will have been overriding the Static Port that you entered, and therefore causing your connection problems.

Regards,

John Marsh 
 

I'd never heard of dynamic ports before. And the reason why I've never run into this issue before was because I've always used the full version of SQL Server that comes with MSDN licenses, and that version, by default, does not use dynamic ports by default, it uses Port 1433, which I expected SQL Server to default to in my case. But for both SQL Server 2005 and SQL Server 2008, the Express edition defaults to use Dynamic Ports when TCP/IP connections are enabled. So all my setting of Port 1433 in the Configuration Manager was completely ignored because it switched right back over to Dynamic Ports. To make things even more confusing, to enable Dynamic Ports, the setting is set to '0'. That's '0', as in the programmatic standard for FALSE, just not in this case, as is thoroughly documented in SQL Server documentation. Heh heh.

So with the Dynamic Ports' setting of '0' removed, I'm up and running. And now this blog (not to mention other, more legitimate sites I run [sic?]) is finally (as of Sunday afternoon) moved off my home PC and onto my new VPS.

So Long, Farewell

by Jon Davis 15. May 2009 02:10

No I'm not killing off my blog. I am, however, going to stop being so cheap, and start hosting my IIS web apps, including this blog, on an external server for a change.

For years now I've been hosting my blog here behind a home cable modem. As I post this--indeed this'll be the last night that this will be the case--I have a cheap virtual dedicated Linux server with Apache proxying out to my home IP on an alternate port. COX only blocks port 80 (the web port, and some other ones like SMTP's), so I have my router at home rigged to redirect traffic on the alternate port back to port 80 and to my internal web server's IP address (this is the same server that "serves" me prerecorded shows on my HDTV via Vista Media Center). The proxy/router setup works, but then COX keeps killing off my Internet connection. I keep having to stand up, go to the back room where the cable modem is, disconnect the cable modem power and coax, wait for 5 seconds, and reconnect everything. (Yes, the coax, too. It doesn't resync unless I do that.)

My web site tends to go offline all day while I'm at work. I've noticed that the disconnects happen routinely at about 3:15 PM and at about 1:45 AM, but they also happen erratically and sporatically throughout the day, and it often stays offline until human intervention (manual shutoff and powerup). And, I am beginning to suspect that they are actually monitoring network traffic and they disconnect me when they see any normal flood of inbound HTTP requests that come from two or more visitors at a time. It might also be heat-related; the disconnects are suddenly much more frequent lately, and coincidentally it's suddenly a lot hotter around here in this Arizona climate.

So I'm finally caving in; short of tunnelling the proxied HTTP packets, I can't beat COX at this game. I'm going to try a VPS from http://www.automatedvps.com/about.php .. They look like an under-established outfit but so far they are not just affordable for Win2008 virtual dedicated hosting, the VPS I've already snagged feels quite performant. I'll have all the Windows play dough I could ask for, and I won't have to worry about my blog or any major web site I might be hosting going offline because COX wants to keep us from hosting stuff.

Incidentally, before signing up with AutomatedVPS.com, I tried Mosso.com's Site Cloud. I'd been slobbering over their Kool Aid for so long, I had to give them a shot. It was ugly, though. Their control panel behaves erratically, frequently showing multiples of new objects being added until you refresh or until a Live Chat support staff deletes the extras. I had to throw the whole thing out when I saw that I had NO control over IIS 7 and the subweb applications and application pools.

------

UPDATE: Ouch. Yeah, that took a lil more time than I expected to transfer everything (see next post re SQL Express and Dynamic Ports), but it's switched now. 

My ‘Aha!’ Moment With Javascript

by Jon Davis 14. May 2009 01:25

9/27/2012 Note: This is an old 2009 blog entry, and it was recently promoted on DZone with no intention of making it a Big Link. I've since learned quite a bit more about Javascript fundamentals, correcting a few misgivings presented here, and you should, too. 

-- 

For most people this goes back to Javascript 101 but it’s worth blogging, in my opinion. A lot of people truly have no idea how much power is available on the client side of web apps, and they actually think that Javascript is dying.

The true power of Javascript was not made known to me until I had my aha! moment. It was about two or three years ago, and I think I could sum up (profusely, with freeze-dried concentration) what triggered my realization when these two essential facts became clear:

Discovery #1:

 

var myFunc = function() { };
var myObj = new myFunc();

 

.. is to Javascript what this is to C# ..

public class MyClass 
{
public MyClass() { } 
}
MyClass myObj = new MyClass();

 

 

That is to say, Javascript functions are functions (of course) but also “classes” (object prototypes) and constructors all rolled into one. So, for example, to accomplish this in C# ..

class MyClass {
void DoSomething() {
MessageBox.Show("something");
}
}
... 
MyClass myObj = new MyClass();
myObj.DoSomething();

.. you could do this in Javascript ..

function myFunc() { }
myFunc.prototype.doSomething = function() {
alert('something');
};
...
var myObj = new myFunc();
myObj.doSomething();

 

Or, you could assign the doSomething member function “at runtime” (dynamically appending the member to the object after the object has already been instantiated).

var myFunc = new function() {
this.doSomething = function() {
alert('something');
};
};
var myObj = new myFunc();
myObj.doSomething();
// or even
myObj.doSomethingElse = function() { alert('something else'); };
myObj.doSomethingElse();

Note that ‘this’ is used to reference the object instance that the function instance is. Incidentally, you can ensure “this” works when calling other objects’ functions by using function_name.call(object, params);.

That said, these things point out the dynamic nature of Javascript object members – you can append properties and functions to an object at runtime by using syntax like [object].doSomething = function() { }. It also shows that members on an object are akin to a string-keyed hashtable.

And that hashtable-like behavior brings about the second part of my “aha!” moment.

Discovery #2:

All user-defined objects, including functions, are ultimately string-keyed hashtables. That is not a limiting behavior but an extra feature because they are still real objects.

But JSON (Javascript object notation) objects are extraordinarily handy as alternatives to functions because of the expressive way you can declare them.

var myNewObject = {
member_A : "abc",
member_B : 123
};

.. is akin to C#’s ..

Dictionary<string, object> myNewObject = new Dictionary<string, object>();
myNewObject["member_A"] = "abc";
myNewObject["member_B"] = 123;

And it’s even more powerful when you consider that the members can be functions.

myNewObject = {
doSomething: function() {
alert('something');
}
};
myNewObject.doSomething(); // invoke
// or,
myNewObject = { };
myNewObject.doSomething = function() {
alert('something');
};
myNewObject.doSomething(); // invoke

.. can be implemented in C# 3.0 like so ..

delegate void SimpleMethod();
public static void RunSnippet()
{
var myNewObject = new Dictionary<string, object>();
myNewObject["doSomething"] = (SimpleMethod)(() =>
MessageBox.Show("something")
);
// .. 
((SimpleMethod)myNewObject["doSomething"])(); // invoke
}

In fact, take a look at this old blog post I saw at Ajaxian.com: http://colinramsay.co.uk/diary/2008/04/02/javascript-generation-a-change-of-heart/

In return, comparing the two languages reveals the power of C# 3.0, as well. C# 4.0’s dynamic objects will be trying even harder to “be powerful like Javascript already was”.

*evil grin*

Quickie Alarm

by Jon Davis 13. May 2009 23:39

I flew out to California on Friday night to visit my siblings, and when I arrived I rented a car and drove around in the middle of the night looking for a cheap place to sleep. After an hour of getting completely lost I finally found a Motel 6 (*shudder*), climbed into bed, and then realized that there’s no alarm clock in the room. Great.

So I threw together another alarm clock on my laptop. I went through the trouble of giving it a nice touch, so it took an hour or two rather than a minute or two, but it did the job and I was proud and still managed to sleep well.

And now I’m sharing it here online. This is freeware with source code included. (Uses free Developer Express controls.)

image

.. click ‘Go’ and ..

image

Download: http://www.jondavis.net/codeprojects/QuickieAlarm/QuickieAlarm.zip


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  September 2018  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar