WinSCP error while uploading file occurring randomly - sftp

We are using WinSCP to transfer files to a SFTP server by invoking commands in .net code. On the other end, an automated process grabs the file and moves it to another location. The below is the .Net code being used.
With winscp.StandardInput
.WriteLine("option batch abort")
.WriteLine("option confirm off")
.WriteLine("open sftp://" & username & ":" & password & "#" & remotehost)
.WriteLine("option transfer binary")
.WriteLine("lcd " & localFilePath)
If Not remoteFilePath Is Nothing Then .WriteLine("cd " & remoteFilePath)
If remoteFileName Is Nothing Then .WriteLine("put " & localFileName) Else .WriteLine("put " & localFileName & " """ & remoteFileName & """")
.Close()
End With
In some cases, when the WinSCP issues the PUT command,
Creates the partial file
Renames it back to original name
The process at the other end moves the file
Then our process creates the partial file again and tries to delete the file with original name.
Not sure why the step#4 is happening, as we don't have any logic in our code to place the partial file again and delete the original file.
Please see the following log from the SFTP server.
2015-03-05 22:30:59 - Account\UserID [3346178]created
/in/YYYXXX.xml.filepart - 226 - 1178853 - 22
2015-03-05 22:31:21 -
Account\UserID [3346178]rnfr /in/YYYXXX.xml.filepart - 350 - - 22
2015-03-05 22:31:21 - Account\UserID [3346178]rnto /in/YYYXXX.xml -
250 - - - 22
2015-03-05 22:31:25 - Account\UserID [3346215]sent
/in/YYYXXX.xml - 226 - 17924096 - 22
2015-03-05 22:31:26 -
Account\UserID [3346220]dele /in/YYYXXX.xml - 250 - - - 22
2015-03-05
22:31:28 - Account\UserID [3346209]created /in/YYYXXX.xml.filepart -
226 - 1178853 - 22
2015-03-05 22:31:28 - Account\UserID [3346209]dele
/in/YYYXXX.xml - 550 - - - 22
From the log the original file(YYYXXX.xml) is already deleted by the other process (refer #5) and gives the below error.
Unable to SFTP XML file. Error Message: from PutSFTP: There was an
error transferring YYYXXX.xml. Error deleting file 'YYYXXX.xml'. After
resumable file upload the existing destination file must be deleted.
If you do not have permissions to delete file destination file, you
need to disable resumable file transfers. No such file or directory.
Error code: 2 Error message from server (en): File not found Request
code: 13
Also there is no pattern in the occurrence of this issue i.e not based on file size, date, etc.
We have already included the option confirm off in the script, so resuming should take place as needed. We are using WinSCP Version 5.0.5 (Build 1782).
Is there anything else we need to change/configure ? Let me know what additional info you need from me.

Have you tried using the .NET assembly that you can get as a separate download? I've been using it for a while and it hasn't given me any problems. WinSCP .NET Library
You may also want to look at this bug report : Here
ResumeSupport requires that the .filepart file be written to the ftp site and deleted or renamed. If you don't have permission, you get an error.
The fix is to turn off resume support by updating the WinSCP.ini file and set ResumeSupport=2
More documentation on Resume support here

Related

Classic ASP migration to Windows 2016 Chilkat Zip Activex issue with temdir

This is as much a note for myself as to help anyone else.
We migrated a Classic ASP application to Window 2016. Everything worked in the end. Then an issue surfaced with some zip & download functionality for which we use a Zip component from Chilkat.
Initially, all looked well - the software component was installed and responded to instantiation, but the zip files did not appear on disk where expected.
What could it be? Modifying the code as:
Set oZip = Server.CreateObject(CHILLKAT_ZIP_OBJECT_NAME)
oZip.UnlockComponent(<the license code>)
oZip.WriteZipAndClose()
Response.Write "<pre>" & Server.HTMLEncode( ozip.LastErrorText) & "</pre>"'
response.end
Produced
ChilkatLog:
WriteZipAndClose:
DllDate: Mar 1 2011
UnlockPrefix: *******
Username: *******
Architecture: Little Endian; 32-bit
Language: ActiveX
tempFile: .\ckz_40NT.tmp
Encryption: 0
PasswordProtected: 0
Failed to open file (2)
filename: .\ckz_40NT.tmp
currentWorkingDirectory: C:\Windows\SysWoW64\inetsrv
osErrorInfo: Access is denied.
Filename: .\ckz_40NT.tmp
Failed to open output Zip file
zipFilename: .\ckz_40NT.tmp
Retrying with a new temp filename
Encryption: 0
PasswordProtected: 0
Failed to open file (2)
filename: .\ckz2_I473.tmp
currentWorkingDirectory: C:\Windows\SysWoW64\inetsrv
osErrorInfo: Access is denied.
Filename: .\ckz2_I473.tmp
Failed to open output Zip file
zipFilename: .\ckz2_I473.tmp
tempFileName: .\ckz2_I473.tmp
Cannot open temporary file
Failed.
What could the prolem be ?
The issue was with chilkat's tempdir setting. On our version of Chilkat Tempdir defaulted to the IIS home folder which is unlikely ever to be happy having random files written to it. Adding a line to set tempdir to something more sensible, as below, cured the issue.
Set oZip = Server.CreateObject(CHILLKAT_ZIP_OBJECT_NAME)
oZip.UnlockComponent(<the license code>)
' added the next line !
oZip.TempDir = Server.MapPath("/some accessible folder path")
oZip.WriteZipAndClose()
Response.Write "<pre>" & Server.HTMLEncode( ozip.LastErrorText) & "</pre>"'
Useful info. I'm a Classic ASP programmer and at some point will need to move from Windows 2012 to Windows 2016. Been putting it off!

Jmeter: Response code: Non HTTP response code: javax.net.ssl.SSLHandshakeException

I have an application URL. I need to run login test using Jmeter. I recorded the login steps using blazemeter extension of chrome. But when I run it I get below error. I know there have been questions like this, I have tried few and it seems my case is different.
I have tried:
Added these two lines in jmeter.bat
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
set PATH=%JAVA_HOME%\bin;%PATH%
Run Jmeter using "Run as Administrator"
Download the certificate from here https://gist.github.com/borisguery/9ef114c53b83e553b635 and install it this way
https://www.youtube.com/watch?v=2k581jcWk9M
Restart the Jmeter but and try again but no luck.
When I expand the error in Jmeter View tree listener I get error on this particular css file: https://abcurl.xyzsample.com/assets/loginpage/css/okta-sign-in.min.7c7cfd15fa939095d61912dd8000a2a8.css
Error:
Thread Name: Thread Group 1-1
Load time: 268
Connect Time: 0
Latency: 0
Size in bytes: 2256
Headers size in bytes: 0
Body size in bytes: 2256
Sample Count: 1
Error Count: 1
Response code: Non HTTP response code: javax.net.ssl.SSLHandshakeException
Response message: Non HTTP response message: Received fatal alert: handshake_failure
Response headers:
HTTPSampleResult fields:
ContentType:
DataEncoding: null
If you are getting error for only one .css file and it does not belong to the application under test (i.e. it is an external stylesheet) the best thing you could do is just to exclude it from the load test via URLs must match section which lives under "Advanced" tab of the HTTP Request Defaults configuration element.
If you need to load this .css by any means you could also try the following approaches:
Play with https.default.protocol and https.socket.protocols properties (look for the above lines in jmeter.properties) file
Install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files into /jre/lib/security folder of your JRE or JDK home (replace existing files with the downloaded ones)
If your url needs a client certificate, then copy your cert to /bin folder and from the jmeter console if you go to options -> SSL Manager and select your cert , it would prompt you for the certificate password . And if you run your tests again , that should work .
Additionally you can also do keystore configuraion (http://jmeter.apache.org/usermanual/component_reference.html#Keystore_Configuration) , if you haven't done already .
Please Note that my jmeter version is 4.0 . Hope this helps .

What causes firePHP to fail to open output stream

I am trying to write a javascript variable to the console but could not so I setup (I think???) firePHP but received
Warning: require(FirePHPCore/fb.php): failed to open stream: No such file or directory in C:\wamp\www\htdocs\replayandsave\public\home\templatehome.php on line 26
line 25
< ? php (had to add spaces to get it to display)
line 26
require('FirePHPCore/fb.php');
Please help I have spent four days trying to get a component to work with dynamically created parameters.
All you have to do is call console.log(variable); in the JavaScript code that PHP is serving. No Need for FirePHP. FirePHP is used to log PHP variables to the browser JavaScript console.

Symfony 2 Missing File Error When They're Not

I got my Symfony 2.3 project working through app.php in development. I then did a complete copy to my shared host sever (goDaddy). So far, all I get are blank pages. I've been working my way through the errors. My lastest execution generates 100+ errors in the php log of this type:
[09-Jul-2013 12:52:56 America/Los_Angeles] PHP Warning: file_get_contents(/Volumes/Data RAID/htdocs/Symfony/src/Zetcho/AmColAnBundle/Resources/views/User/userSubNav.html.twig) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/content/.../Symfony/vendor/symfony/symfony/src/Symfony/Component/Templating/Storage/FileStorage.php on line 32
Then I get one of theses
[09-Jul-2013 12:52:56 America/Los_Angeles] PHP Warning: file_get_contents(/Volumes/Data RAID/htdocs/Symfony/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/content/.../Symfony/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 127
The ellipses are mine. I verified that the file that both files were was at the locations specified and that I could read it. The permissions on the files are 644. Could this be a permission problem? If so, what should they be set to?
Update: I set the permissions to 755 and got the same errors.
Update 2: I just noticed that the error is giving my development server directory path. Now I just have to figure out where to change it.
Update 3: It appears to be the cache. There is not command access to a goDaddy shared server that I know of so I just deleted all the files in app/cache/prod. I now get my html, but no css. I use Assetic for images and css. I get the images.
Update 4: When I clicked on a link, the next page used the css file. When I went back to the first page, it used it as well. As I check out the pages, some of the images are missing. Could this be because the cache wasn't rebuilt correctly or completely?
Update 5: Fixed the last problem with missing images. There was a case mismatch between the reference and the image. I think I'm good now.

What is a swap file?

Using vi I started editing a html file and I accidentally exited out of session, now when I try to edit the file again I receive this message :
E325: ATTENTION Found a swap file by the name ".myfile.swp" While
opening file "myfile.html"
dated: Tue Jul 3 09:55:39 2012
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r myfile.html"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".myfile.html.swp"
to avoid this message.
Swap file ".myfile.html.swp" already exists!
Has any damage occured to myfile.html ?
What I think is occuring is that its storing a copy of the opened file when I exited my session (the swap file) ?
From the Vim documentation:
Vim stores the things you changed in a swap file. Using the original
file you started from plus the swap file you can mostly recover your
work.
The documentation also describes the recovery procedure in case you need it.

Resources