Is there a way to read the raw ftp server response?

0 votes
asked Oct 22 by mdaustin (150 points)

I'm hoping someone here can help me out. I am trying to read the response from the ftp server after a PutFile command. If I try to simply read the response:

jobid = client.PutFile(localFileName, filename);
response = client.ReadResponse();

I get this error:
System.InvalidOperationException: No response from the server is expected.

Yet in the log fie there re two responses after the STOR command is sent.

Command: STOR ZENT001A.jcl
Response: 125 Accepting JCL to submit
Response: 250 It is known to JES as J0001904

Is there a way to read the raw ftp server response?

Here is the log file for the entire transaction.

2019-10-21 10:54:22.454 INFO Ftp(1)[15] Response: 230 User XXXXXX logged in. Working directory is "XXXXXX."
2019-10-21 10:54:22.459 INFO Ftp(1)[15] Command: FEAT
2019-10-21 10:54:22.498 INFO Ftp(1)[15] Response: 211-Extensions Supported
2019-10-21 10:54:22.498 INFO Ftp(1)[15] Response: AUTH TLS
2019-10-21 10:54:22.498 INFO Ftp(1)[15] Response: PBSZ
2019-10-21 10:54:22.498 INFO Ftp(1)[15] Response: PROT
2019-10-21 10:54:22.498 INFO Ftp(1)[15] Response: 211 End
2019-10-21 10:54:22.512 INFO Ftp(1)[15] Command: SITE filetype=jes
2019-10-21 10:54:22.548 INFO Ftp(1)[15] Response: 200 SITE command was accepted
2019-10-21 10:54:22.549 INFO Ftp(1)[15] Command: PASV
2019-10-21 10:54:22.585 INFO Ftp(1)[15] Response: 227 Entering Passive Mode (10,99,36,34,39,16)
2019-10-21 10:54:25.389 INFO Ftp(1)[15] Command: TYPE A
2019-10-21 10:54:25.425 INFO Ftp(1)[15] Response: 200 Representation type is Ascii NonPrint.
2019-10-21 10:54:25.427 INFO Ftp(1)[15] Command: PASV
2019-10-21 10:54:25.464 INFO Ftp(1)[15] Response: 227 Entering Passive Mode (10,99,36,34,39,16)
2019-10-21 10:54:25.506 INFO Ftp(1)[15] Command: STOR ZENT001A.jcl
2019-10-21 10:54:25.542 INFO Ftp(1)[15] Response: 125 Accepting JCL to submit
2019-10-21 10:54:26.085 INFO Ftp(1)[15] Response: 250 It is known to JES as J0001904
2019-10-21 10:54:32.442 ERROR Ftp(1)[15] Info: System.InvalidOperationException: No response from the server is expected.

Thanks.

Applies to: Rebex FTP/SSL

1 Answer

0 votes
answered Oct 22 by Lukas Pokorny (103,170 points)
selected Oct 22 by mdaustin
 
Best answer

When the PutFile method finishes, it has already transferred the file and read all outstanding responses. There is no further response to be read at that point and therefore the ReadResponse method fails.

To capture responses processed by the PutFile method, use Ftp object's ReadResponse event (add a custom event handler before the PutFile method is called and remove it afterwards).

commented Oct 22 by mdaustin (150 points)
Thank you. That was just what I was looking for.
...