denisenkom / go-mssqldb

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

Ping automatically changes the port to 1434. I used the connection string with Port 1433. I can connect but when I ping it is getting timedout. #793

Open nanduIyer opened 9 months ago

nanduIyer commented 9 months ago

Describe the bug @LuisBosquez When I tried to connect to SQL Server, it got connected. Unable to ping or query the tables.

connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d;", MES_DB_SERVER, MES_USERNAME, MES_PASSWORD, MES_PORT) fmt.Println(connString) //conS := fmt.Sprintf("sqlserver://%s:%s@%s:$d/") // create connection pool dbcon, err = sql.Open(MES_DB_TYPE, connString) if err != nil { log.Fatal("Error creating connection pool: " + err.Error()) } log.Printf("Connected!\n")

When I ping I am getting error ctx := context.Background()

err := dbcon.PingContext(ctx)
if err != nil {
    log.Fatal("Error pinging DB : ", err.Error())
}

If you see the error message it says udp with 1434. I checked TCP is enabled and restarted the db several times. Any help will be appreciated. Error message:

PS C:\Users\g_nan\Documents\Goworkspace\DatabaseSQLGo> go run main.go server=NANDU\SQLEXPRESS;user id=SA;password=Sapwd1298;port=1433; 2023/12/22 23:27:48 Connected! 2023/12/22 23:28:03 Error pinging DB : unable to get instances from Sql Server Browser on host NANDU: read udp [fe80::c635:3f67:afd0:eaef%Ethernet 3]:63108->[fe80::c635:3f67:afd0:eaef%Ethernet 3]:1434: i/o timeout exit status 1

If you are seeing an exception, include the full exceptions details (message and stack trace).

Exception message:
PS C:\Users\g_nan\Documents\Goworkspace\DatabaseSQLGo> go run main.go
server=NANDU\\SQLEXPRESS;user id=SA;password=Sapwd1298;port=1433;
2023/12/22 23:27:48 Connected!
2023/12/22 23:28:03 Error pinging DB : unable to get instances from Sql Server Browser on host NANDU: read udp [fe80::c635:3f67:afd0:eaef%Ethernet 3]:63108->[fe80::c635:3f67:afd0:eaef%Ethernet 3]:1434: i/o timeout
exit status 1

Stack trace:

To Reproduce Include a complete code listing that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

Expected behavior A clear and concise description of what you expected to happen.

Further technical details

SQL Server version: express edition Operating system: windows 11 Table schema

Additional context Add any other context about the problem here.

SantiiRepair commented 1 week ago

same issue for me, I've set port to 1433

read udp 127.0.0.1:49834->127.0.0.1:1434: i/o timeout