Skip to Content.
Sympa Menu

freetds - [freetds] MAMP, FreeTDS, ODBC, and ssh tunnel port forwarding almost working...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Andrew Rousseau <andrew AT bluehousegroup.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] MAMP, FreeTDS, ODBC, and ssh tunnel port forwarding almost working...
  • Date: Sun, 14 Sep 2014 21:44:48 -0400

I am attempting to connect with php to a remote mssql server. Since the
mssql server is behind a firewall, I am using ssh tunnel with port
forwarding to access it from my Macbook.

$ ssh -N -L 1433:<mssql_server_ip>:1433 username AT www.example.com

The tunnel works fine as I am able to use Navicat to connect to the mssql
server and I am able to telnet to it. I think I have freetds and odbc
installed correctly and running under MAMP locally. It is only php that is
unable to connect to the server. Which leads me to believe that there is
some small piece of my configuration that is causing it to fail. I also am
thinking that the tunnel and port forwarding may be an issue for freetds.

>From php I am attempting to connect the same way I am successfully
connecting on my linux production server:

$db = new PDO('odbc:Driver=FreeTDS; Server=127.0.0.1; Port=1433;
Database=db_name; UID=user; PWD=password;');

Here is the output of a tdsdump:

$ TDSDUMP=/tmp/freetds.log TDSVER=7.1 tsql -H 127.0.0.1 -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 61, "Connection refused"
There was a problem connecting to the server

$ tail -f /tmp/freetds.log
log.c:196:Starting log file for FreeTDS 0.91
on 2014-09-14 21:36:55 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x7fb50bc04250, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF-8"
iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to 127.0.0.1 port 1433 (TDS version 7.1)
net.c:270:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:306:getsockopt(2) reported: Connection refused
net.c:316:tds_open_socket() failed
util.c:331:tdserror(0x7fb50bc04150, 0x7fb50bc04250, 20009, 61)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
mem.c:615:tds_free_all_results()


Any help would be greatly appreciated!




Archive powered by MHonArc 2.6.24.

Top of Page