5

I have a java.nio.channels.SocketChannel in my jSCSI implamantation that is disconnecting when I try to open a driver with size greater than 4GB. The iscsi RFC says that the BasicHeaderSegment.BHS_FIXED_SIZE may be 48, so with this position I can read the bytes on the channel. The java doc says 5 types of errors, but my app is throwing the last one that doesn't say a specific information.

  1. NotYetConnectedException
  2. ClosedChannelException
  3. AsynchronousCloseException
  4. ClosedByInterruptException
  5. IOException

Code:

public final int read(final SocketChannel sChannel) throws InternetSCSIException, IOException, DigestException {
// read Basic Header Segment first to determine the total length of this
// Protocol Data Unit.
clear();

final ByteBuffer bhs = ByteBuffer.allocate(BasicHeaderSegment.BHS_FIXED_SIZE);
int len = 0;
while (len < BasicHeaderSegment.BHS_FIXED_SIZE) {
    int lens = sChannel.read(bhs);
    if (lens == -1) {
        // The Channel was closed at the Target (e.g. the Target does
        // not support Multiple Connections)
        // throw new ClosedChannelException();
        return lens;
    }
    len += lens;
    LOGGER.trace("Receiving through SocketChannel: " + len + " of maximal " + BasicHeaderSegment.BHS_FIXED_SIZE);

}
bhs.flip();

error:

java.io.IOException: An existing connection was forcibly closed by the remote host
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:197)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
    at org.jscsi.parser.ProtocolDataUnit.read(ProtocolDataUnit.java:417)
    at org.jscsi.target.connection.TargetSenderWorker.receiveFromWire(TargetSenderWorker.java:145)
    at org.jscsi.target.connection.Connection$TargetConnection.receivePdu(Connection.java:217)
    at org.jscsi.target.connection.phase.TargetFullFeaturePhase.execute(TargetFullFeaturePhase.java:96)
    at org.jscsi.target.connection.Connection$TargetConnection.call(Connection.java:264)
    at org.jscsi.target.connection.Connection$TargetConnection.call(Connection.java:79)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
[pool-9-thread-1] INFO org.jscsi.target.connection

Thanks in advance, Felipe

user207421
  • 305,947
  • 44
  • 307
  • 483
Felipe Gutierrez
  • 525
  • 1
  • 9
  • 20
  • Note the correction to your title. Your SocketChannel is still open. It is the *connection* that was forcibly closed. – user207421 Jun 09 '14 at 18:13

2 Answers2

4

Your problem description is incorrect. The SocketChannel isn't closed: the connection is; and it isn't happening when you try to open the connection: it is happening when you read from it.

This usually results from sending something after the peer has already closed the connection, which in turn usually means you had previously sent it something it didn't understand.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I am searching on this link the properties of iscsi, maybe I can increase the timeout, but I dont know what to edit http://blogs.msdn.com/b/san/archive/2008/07/27/microsoft-iscsi-software-initiator-isns-server-timers-quick-reference.aspx – Felipe Gutierrez Jun 09 '14 at 20:29
  • Timeouts have nothing to do with it. You don't seem to have read this answer. – user207421 Jun 10 '14 at 09:33
0

It looks like the other side disconnected you due to some kind of problem. Assuming you're developing the initiator, you should check the target (server) system logs.

Can you explain the 4GB comment? I mean, what exactly does "open a driver with size greater than 4GB" mean, what driver?

  • I got to mount drivers multiplied for 2. eg: 4Gb, 8GB, 16GB – Felipe Gutierrez Jun 10 '14 at 16:13
  • You mean "drive", eg. a LUN, disk, right? So, the 4GB looks suspicious. There is nothing in iSCSI itself that could have an edge condition related to 4GB. Perhaps it's a SCSI-level problem? Again, anything interesting in target logs? – Edward Tomasz Napierala Jun 11 '14 at 09:52