denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.81k stars 493 forks source link

Named Instance - Not using port sets hard requirement on SQL Server Browser #714

Open Salatbesteck opened 2 years ago

Salatbesteck commented 2 years ago

When working with named instances, the default mssql behavior is to use UDP on port 1434 with the SQL Server Browser to look up the port of the instance. However, when Browser Service is not running or blocked by firewall rules, no connection can be made. In other languages/drivers, this can be solved by passing the port explicitly. In this driver, even using:

sqlserver://{{username}}:{{password}}@/?database=&port=

or

sqlserver://{{username}}:{{password}}@[:port]/?database=

In both cases, port specification is ignored by the driver (this is expected behavior according to the docs). This way no connection with the scenario above is possible.

EnderBlue commented 2 years ago

I am also running into this same issue. The customer we are working with is blocking the use of the SQL Server Browser. We need to be able to supply both the Instance name and the port.

shueybubbles commented 2 years ago

this could be the first PR that goes through in the Microsoft fork

Please take a look https://github.com/microsoft/go-mssqldb/pull/6