0

We have a server that connects to 40+ different remote computers which are running Sybase 11.0.1.2596. Our server is hosted on an aws ec2 AMI Linux instance, and the connections are set up using FreeTDS. The server has several different command-line PHP scripts that use PDO with dblib to connect and select data. 99+% of the time everything works, but sometimes I get these errors:

SQLSTATE[HY000]: General error: PDO_DBLIB: dbresults() returned FAIL

SQLSTATE[HY000]: General error: 20047 TDS: unexpected token 56 [20047] (severity 1) [(null)]

SQLSTATE[HY000]: General error: 20047 DBPROCESS is dead or not enabled [20047]

They seem to happen randomly, and I can't figure out what is causing them or how to fix it. If I just wait, it will start working again. It also seems if I use tsql to connect it will start responding:

tsql -S <odbc name> -U <username>

Any advice is greatly appreciated.

4
  • 1
    What Sybase engine is this? Sybase ASE? SQL Anywhere? Those errors look like connectivity problems, perhaps there are network issues? – Hannah Vernon Mar 28 '17 at 19:53
  • @Max Vernon, The remote computers use SQL Anywhere. I've tried pinging the computers when I get the errors above and the pings all return normally. It seems that maybe the database itself becomes unreachable? – raphael75 Mar 29 '17 at 11:05
  • Ping is not a reliable measure of reliability (it simply shows if there is a pathway at the time of the ping. I'm thinking there is an intermittent connectivity problem that is occasionally causing the unexpected token error. Running netstat -s in Linux will show you if there are any networking errors it's aware of, and might help in diagnosis. – Hannah Vernon Mar 29 '17 at 12:06
  • 1
    I will try that next time it happens & report what it shows. Thank you! – raphael75 Mar 29 '17 at 12:35
0

TDS: unexpected token

  • TDS (transaction Data Stream) is the application layer protocol of Sybase & MS SQL for communication between OpenClient & OpenServer
  • The sample messages in the post point to TDS exchange between ASE & DB-LIB client not being in sync according to the TDS protocol
  • The network exchange machine state in the affected TDS connection at the ASE OpenServer end is not expecting a request from the DB-LIB client for any resultset
  • The above situation may happen if an existing DB-LIB client is picking up a new TDS connection instead of the original one to continue with getting the resultset from a query submitted earlier
  • A typical scenario would involve a pool of connections from a Sybase client to the ASE, should an existing client incorrectly switches to another connection in the pool after submitting a query, the OpenServer of the new, incorrect connection would not understand the client's TDS token requesting resultset
  • Another possible root-cause could be network issue because 56 is not a valid TDS token (0x38 is not a valid token nor 0x56)
  • BTW, DB-LIB is an arcane, unsupported Sybase client (newer, supported Sybase client is CT-LIB)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.