MSSQL17 ODBC can't connect, how do I debug?

I’m trying to make pyodbc work with mssql17 odbc, but it’s failing as documented in this bug msodbc17: TCP Provider: Error code 0x10 · Issue #235407 · NixOS/nixpkgs · GitHub

I would like to try and tackle this until the maintainer of the package is heard back from, but I’m not sure where to start. Right now, I’m testing with iusql which is a generic CLI for making connections to an SQL database using unixODBC. Basically, unixodbc is a library that dynamically loads the mssql17 ODBC library. When it tries to establish a connection with the port that docker opened to the mssql server, it fails.
This is only the case with the library packaged by nix
Outside of nix, the connection is established fine.

The nix package does some patchelf magic nixpkgs/default.nix at e7603eba51f2c7820c0a182c6bbb351181caa8e7 · NixOS/nixpkgs · GitHub . It’s not clear to me how to check if that failed besides running ldd, but that looks OK

ldd output
$ ldd /nix/store/m72z6pjjgy2d4m3fsipl4jx18i2bwamx-msodbcsql17- (0x00007ffc310f4000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a6410000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a640b000) => /nix/store/x156lay2m0gcvwxflr8xfsii081gmy7i-unixODBC-2.3.11/lib/ (0x00007f47a63ec000) => /nix/store/1zy45clchypamqmqq63zcixns02fg2l9-libkrb5-1.20.1/lib/ (0x00007f47a6312000) => /nix/store/1zy45clchypamqmqq63zcixns02fg2l9-libkrb5-1.20.1/lib/ (0x00007f47a62bd000) => /nix/store/7ls5xhx6kqpjgpg67kdd4pmbkhna4b6c-gcc-12.2.0-lib/lib/ (0x00007f47a5bda000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a5afa000) => /nix/store/7ls5xhx6kqpjgpg67kdd4pmbkhna4b6c-gcc-12.2.0-lib/lib/ (0x00007f47a629c000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a6297000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a5914000) => /nix/store/1zy45clchypamqmqq63zcixns02fg2l9-libkrb5-1.20.1/lib/ (0x00007f47a6266000) => /nix/store/1zy45clchypamqmqq63zcixns02fg2l9-libkrb5-1.20.1/lib/ (0x00007f47a625f000) => /nix/store/1zy45clchypamqmqq63zcixns02fg2l9-libkrb5-1.20.1/lib/ (0x00007f47a6250000) => /nix/store/yzqwq9gd0r62n97ab51qdsb3gg1vq7aa-keyutils-1.6.3-lib/lib/ (0x00007f47a6249000) => /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/ (0x00007f47a6234000)
        /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib64/ (0x00007f47a6417000)

My next step will be to use wireshark to monitor the traffic and see if any packets are making it to the port from the program, but since it’s working from outside of docker, it’s my suspicion that the problem is within the packaged lib…

strace seems like overkill and it’s very noisy, so I wouldn’t know what to be looking for.

What other things could I try?

Wireshark did help out. Observed DNS requests being made to name I gave to ODBC internally, instead of ODBC trying to contact the configured server. That led to checking the odbc.ini documentation to end up on pyodbc, where I found out MS doesn’t even Servername, but uses Server :roll_eyes:

Once that was done, msodbc started failing because it couldn’t find an ancient openssl (1.1) in the library path. After that was applied, it worked. Details are in the link issue on github.