I have successfully established a connection to SQL Server
6.5's named pipe, but when JCIFS sends the intial TDS 4.2
logon packet to the server, the server responds with a
1-byte data packet, and JCIFS throws an exception:
jcifs.smb.SmbException: A device attached to the system is
not functioning.
My best guess is that SQL Server 6.5 needs its TDS 4.2
packets padded by 1 byte within the SMB packet to make the
TDS 4.2 packet even-byte-aligned. I'm planning to write the
JCIFS mailing list to ask about how to go about doing this.
The only other differences in the communication are:
JCIFS establishes an anonymous SMB session with SQL Server
6.5, while SQL Enterprise Manager apparent has no session
established.
Some permission bits on various SMB packets do not match.
BTW, I'm using ethereal to sniff the network traffic and
break down the SMB packets for me.
Here is a description of the changes in the patch
(jtds-0.8.1-named-pipes-v1.diff):
Changed version from 0.8.1 to 0.8.1np.
Added 'namedpipe' boolean property (defaults to false).
Extracted TdsIpc abstract base class from TdsSocket class,
and made TdsSocket extend TdsIpc.
Added TdsNamedPipe class extending TdsIpc.
SEVERELY HACKED Tds.logon() to emit a TDS 4.2 logon packet
identical to what SQL Enterprise Manager emits when
connecting to the server. (These changes will need to be
rolled out and/or incorporated once the issue above is solved.)
HACKED TdsComm.sendPhysicalPacket() to emit "byte 6" that
matches output of SQL Enterprise Manager. (Remaining
changes are for TdsIpc class.)
Remaining changes are related to above items.
TODO:
Clean up hacks in Tds.logon() and
TdsComm.sendPhysicalPacket().
Send actual SQL statements in "TransactNmPipe Request"
packets instead of "Write AndX Request" SMB packets. (This
is my best guess as to what SQL Enterprise Manager is
doing.) This may require some modifications to JCIFS, or at
least working around its API. It would also require jTDS to
use two different in/out streams for communication. Not
sure if this is really necessary, though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Attached patch against jTDS-0.8.1 that implements named pipe
IPC using an unmodified jCIFS-0.9.5 library.
Here is a description of the changes in the patch
(jtds-0.8.1-named-pipes-v2.diff):
Changed version from 0.8.1 to 0.8.1np.
Added 'namedpipe' boolean property (defaults to false).
Extracted TdsIpc abstract base class from TdsSocket class,
and made TdsSocket extend TdsIpc.
Added TdsNamedPipe class extending TdsIpc.
Caveats:
There is no "timeout" parameter set on the named pipes,
which may cause issues such as SAfeTest.testCancel0002()
hanging below.
SAfeTest.testCancel0002() will HANG when run against SQL
Server 6.5 using named pipes. (I have no way to test with
TCP/IP.)
Test suite runs as follows, although most failures are
probably due to SQL Server 7+ features (note that
SAfeTest.testCancel0002() was NOT run):
Tests run: 177, Failures: 5, Errors: 41, Time elapsed: 120.264
Although Microsoft's documentation mentions that one may
change the location of the named pipe from /sql/query to
something else, the driver currently doesn't support this.
(However, it would be trivial to add another property to
supply the path, or to set up a different URL that includes
the path.)
Setting the "instance" parameter should work (TdsNamedPipe
takes this into account), but is UNTESTED.
Connecting to SQL Server 7 or 2000 via named pipes is
UNTESTED (but in theory should simply work).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Attaching patch against jTDS-0.9-alpha1 (0.9-cvs) that
implements named pipe IPC.
Tested with jCIFS-0.9.5 (version 0.9.6 just came out last
night and should work fine) and SQL Server 6.5.
THIS PATCH IS A WORK IN PROGRESS.
Todo:
Extract abstract base class (SharedIpc) from SharedSocket
and SharedNamedPipe classes.
Fix timeout issue for named pipes.
(SAfeTest.testCancel0002() hangs because of this.) This
will either be implemented using a TransactNamedPipe or a
timer similar to the LoginTimer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I applied your patch as you submitted it with one exception.
I added a temporary method to set the timeout for TCP/IP
connections in order to keep that functionatliy working.
-Brian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
WIP: Implement named pipe IPC using JCIFS-0.9.5 (BROKEN)
Logged In: YES
user_id=84089
The first attached patch is an initial pass at implementing
named pipe IPC (interprocess communication) using JCIFS-0.9.5.
http://jcifs.sourceforge.net/
I have successfully established a connection to SQL Server
6.5's named pipe, but when JCIFS sends the intial TDS 4.2
logon packet to the server, the server responds with a
1-byte data packet, and JCIFS throws an exception:
jcifs.smb.SmbException: A device attached to the system is
not functioning.
My best guess is that SQL Server 6.5 needs its TDS 4.2
packets padded by 1 byte within the SMB packet to make the
TDS 4.2 packet even-byte-aligned. I'm planning to write the
JCIFS mailing list to ask about how to go about doing this.
The only other differences in the communication are:
6.5, while SQL Enterprise Manager apparent has no session
established.
BTW, I'm using ethereal to sniff the network traffic and
break down the SMB packets for me.
http://www.ethereal.com/
Here is a description of the changes in the patch
(jtds-0.8.1-named-pipes-v1.diff):
and made TdsSocket extend TdsIpc.
identical to what SQL Enterprise Manager emits when
connecting to the server. (These changes will need to be
rolled out and/or incorporated once the issue above is solved.)
matches output of SQL Enterprise Manager. (Remaining
changes are for TdsIpc class.)
TODO:
TdsComm.sendPhysicalPacket().
packets instead of "Write AndX Request" SMB packets. (This
is my best guess as to what SQL Enterprise Manager is
doing.) This may require some modifications to JCIFS, or at
least working around its API. It would also require jTDS to
use two different in/out streams for communication. Not
sure if this is really necessary, though.
Implement named pipe IPC using jCIFS-0.9.5 (FIXED)
Logged In: YES
user_id=84089
Attached patch against jTDS-0.8.1 that implements named pipe
IPC using an unmodified jCIFS-0.9.5 library.
Here is a description of the changes in the patch
(jtds-0.8.1-named-pipes-v2.diff):
Changed version from 0.8.1 to 0.8.1np.
Added 'namedpipe' boolean property (defaults to false).
Extracted TdsIpc abstract base class from TdsSocket class,
and made TdsSocket extend TdsIpc.
Added TdsNamedPipe class extending TdsIpc.
Caveats:
There is no "timeout" parameter set on the named pipes,
which may cause issues such as SAfeTest.testCancel0002()
hanging below.
SAfeTest.testCancel0002() will HANG when run against SQL
Server 6.5 using named pipes. (I have no way to test with
TCP/IP.)
Test suite runs as follows, although most failures are
probably due to SQL Server 7+ features (note that
SAfeTest.testCancel0002() was NOT run):
Tests run: 177, Failures: 5, Errors: 41, Time elapsed: 120.264
Although Microsoft's documentation mentions that one may
change the location of the named pipe from /sql/query to
something else, the driver currently doesn't support this.
(However, it would be trivial to add another property to
supply the path, or to set up a different URL that includes
the path.)
Setting the "instance" parameter should work (TdsNamedPipe
takes this into account), but is UNTESTED.
Connecting to SQL Server 7 or 2000 via named pipes is
UNTESTED (but in theory should simply work).
WIP: Implement named pipe IPC for 0.9-alpha1
Logged In: YES
user_id=84089
Attaching patch against jTDS-0.9-alpha1 (0.9-cvs) that
implements named pipe IPC.
Tested with jCIFS-0.9.5 (version 0.9.6 just came out last
night and should work fine) and SQL Server 6.5.
THIS PATCH IS A WORK IN PROGRESS.
Todo:
Extract abstract base class (SharedIpc) from SharedSocket
and SharedNamedPipe classes.
Fix timeout issue for named pipes.
(SAfeTest.testCancel0002() hangs because of this.) This
will either be implemented using a TransactNamedPipe or a
timer similar to the LoginTimer.
Logged In: YES
user_id=716174
David,
I applied your patch as you submitted it with one exception.
I added a temporary method to set the timeout for TCP/IP
connections in order to keep that functionatliy working.
-Brian