login about faq

Hi, We have been using Chilkat.SFTP inside of a Microsoft SQL Server Stored Procedure for years. It connects to a secure FTP site, uploads a file, then scrolls through some directories and pulls down any files that are out there for us. We don't own or control the SFTP server.

In the last couple months, the job is getting stuck (I don't know how else to put it). For example, today I found 86 files had been downloaded through the job, but when I checked, the job was still running. There was a 0-kb file locked open on my local operating system which said it was being held by SQL Server.

It takes re-booting the local machine in order to clear the file lock to be able to delete it. The calls to the Chilkat API aren't reporting any errors. It's like the file gets opened locally for writing and the whole process grinds to a halt.

I'm looking for suggestions on ideas for my Stored Procedure code to somehow know something went wrong and to release the file lock?

Here's the Cliff's notes of our current process:

sp_OACreate 'Chilkat.SFtp', @sftp OUT
EXEC sp_OASetProperty @sftp, 'ConnectTimeoutMs', 5000
EXEC sp_OASetProperty @sftp, 'IdleTimeoutMs', 10000
EXEC sp_OAMethod @sftp, 'Connect', @success OUT, @hostname, @port
EXEC sp_OAMethod @sftp, 'AuthenticatePw', @success OUT, @as_user, @as_password
EXEC sp_OAMethod @sftp, 'InitializeSftp', @success OUT
... skip the uploading part, no issues there
EXEC sp_OAMethod @sftp, 'OpenDir', @handle OUT, @as_directory
EXEC sp_OAMethod @sftp, 'ReadDir', @dirListing OUT, @handle
EXEC sp_OAGetProperty @dirListing, 'NumFilesAndDirs', @n OUT
... loop through @n
EXEC sp_OAMethod @dirListing, 'GetFileObject', @fileObj OUT, @I
EXEC sp_OAGetProperty @fileObj, 'Filename', @sTmp0 OUT
EXEC sp_OAMethod @sftp, 'OpenFile', @filehandle OUT, @tmp, 'readOnly', 'openExisting'
EXEC sp_OAMethod @sftp, 'DownloadFile', @success OUT, @filehandle, @fullDownloadFile
EXEC sp_OAMethod @sftp, 'CloseHandle', @success OUT, @filehandle
EXEC sp_OAMethod @sftp, 'RemoveFile', @success OUT, @tmp
... end loop through @n
EXEC sp_OAMethod @sftp, 'CloseHandle', @success OUT, @handle

Any thoughts?

Thanks!

asked Nov 16 at 13:53

JohnR's gravatar image

JohnR
1

edited Nov 16 at 13:55

chilkat's gravatar image

chilkat ♦♦
11.8k316358420


The first thing to do is to make sure you're using the very latest version of Chilkat.

If the problem remains, turn on verbose logging via the VerboseLogging property, and set the DebugLogFilePath property to the name of a log file that would be created by Chilkat. (It must be a path with directory permissions for your SQL Server process to create the file on the local filesystem.) Then re-run and examine the log file that gets created once it hangs.

link

answered Nov 16 at 13:57

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Hi. I added the verbose logging and the debug file. After an hour, I have got a 200Mb file and growing with no way to stop it. I am getting a repeated section (below). The only difference between each section that I can see is "packetLen" changes, one value in "payload" (example below first one is EF9E, second is EF9F), and "m_curServerWinSize". The file size on the local machine is still 0 kb.

readChannelData:
    clientChannelNum: 0
    totalTimeoutMs: 0
    bCheckQueue: 1
    bOnlyExtendedData: 0
    bSkipExtendedData: 1
    idleTimeoutMs_1: 0
    calledFrom: 103
    bReadOneRaw: 0
    (leaveContext)
Decrypting first block of message..
packetLen: 188
mType: CHANNEL_DATA
payloadMsgType: 94
payloadLen: 41
payload: 5E00 0000 0000 0000 2000 0000 1C65 0001

EF9E 0000 0004 0000 000B 456E 6420 6F66 2046 696C 6500 0000 00 packetType: SSH_FXP_STATUS StatusResponse: Request: SSH_FXP_READ StatusCode: 4 StatusMessage: End of File (leaveContext) Unexpected status response. sendFxpRead: sendPacket: packetType: SSH_FXP_READ m_curServerWinSize: 273675 sendMessage: msgName: CHANNEL_DATA unpaddedLength: 41 remainder: 9 paddingLen: 7 totalSize: 48 (leaveContext) (leaveContext) (leaveContext)

readChannelData:
    clientChannelNum: 0
    totalTimeoutMs: 0
    bCheckQueue: 1
    bOnlyExtendedData: 0
    bSkipExtendedData: 1
    idleTimeoutMs_1: 0
    calledFrom: 103
    bReadOneRaw: 0
    (leaveContext)
Decrypting first block of message..
packetLen: 92
mType: CHANNEL_DATA
payloadMsgType: 94
payloadLen: 41
payload: 5E00 0000 0000 0000 2000 0000 1C65 0001

EF9F 0000 0004 0000 000B 456E 6420 6F66 2046 696C 6500 0000 00 packetType: SSH_FXP_STATUS StatusResponse: Request: SSH_FXP_READ StatusCode: 4 StatusMessage: End of File (leaveContext) Unexpected status response. sendFxpRead: sendPacket: packetType: SSH_FXP_READ m_curServerWinSize: 273648 sendMessage: msgName: CHANNEL_DATA unpaddedLength: 41 remainder: 9 paddingLen: 7 totalSize: 48 (leaveContext) (leaveContext) (leaveContext)

link

answered Nov 17 at 08:14

JohnR's gravatar image

JohnR
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×200
×7

Asked: Nov 16 at 13:53

Seen: 116 times

Last updated: Nov 17 at 08:14

powered by OSQA