How to change the port on a mssql named instance?

(Bart) #1

We don’t use the default port 1433 for our MSQL databases. we use a different port: 1450
However, the pack keeps going to this default port.

Does anyone know how to change the port number?

I’ve tried with “servername:1450” and “servername, 1450”, but with no success.

I keep getting the following error

  "result": "None",
  "exit_code": 1,
  "stderr": "st2.actions.python.MSSQLRunner: ERROR    (20009, 'DB-Lib error message 20009, severity 9:\\nUnable to connect: Adaptive Server is unavailable or does not exist (\\nNet-Lib error during Connection refused (111)\\n')\n",
  "stdout": ""

can anyone help?



The mssql pack does not (yet) support an explicit port, but it should support the servername:port syntax for the server key. Can you post the error when you use that in the mssql.yaml config file?

(Lindsay Hill) #3

Looking at the docs for the underlying pymssql library, tote that other style it also says it accepts: 'SQLHOST,1433' - See how there’s no space between hostname & port number?

pymssql.connect() also supports a port= parameter, with a default of '1433'. Should be pretty trivial to hack that into the pack, to test doing it that way?

(Lindsay Hill) #4

I made a few very quick changes to the MSSQL pack to allow specifying a port here.

You could try it out by installing that branch with st2 pack install mssql=port. Then specify the port in either your action parameters or in the config.

Have not tested those code changes at all, so if you do try it, let us know how you get on.

(Bart) #5

Thanks for the quick help Lindsay!

i’ve installed the branch you added and specified the port number in the mssql.yaml config file.
No longer the same error, but something else now:

  "result": "None",
  "exit_code": 1,
  "stderr": "Traceback (most recent call last):\n  File \"/opt/stackstorm/runners/python_runner/python_runner/\", line 320, in <module>\n\n  File \"/opt/stackstorm/runners/python_runner/python_runner/\", line 179, in run\n    output =**self._parameters)\nTypeError: run() got an unexpected keyword argument 'port'\n",
  "stdout": ""

Best regards,

(Lindsay Hill) #6

I’ve pushed a fix for that which you can install.

I don’t have any MSSQL servers to test against, and have done no testing of this.

There’s not much code to the pack though, so you should be able to work out what’s broken if it still fails.