If I run it from a Windows service, it hangs.

Advertisement

ToniJ
Guest

If I run it from a Windows service, it hangs.

Hi everybody,

My little application in VB6 uses successfully WinSCPnet.dll for connect to SFTP.
But if I use it from a Windows service, it freezes when trying to connect.
Could you help me,

Thanks and congratulations.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,731
Location:
Prague, Czechia

Re: If I run it from a Windows service, it hangs.

How did register the assembly for all users?

Please set Session.SessionLogPath and Session.DebugLogPath and post the logs.

Reply with quote

ToniJ
Guest

Here is the WinSCP[SessionLogPath].log

Here is the WinSCP[SessionLogPath].log
  • session.log (12.63 KB, Private file)

Reply with quote

Advertisement

ToniJ
Guest

Here is how I register it.

C:\windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe "C:\NTV\DLL\WinSCPnet.dll" /codebase /tlb
and the winscp.exe is in C:\NTV\DLL, too.
Version: 5.18.3.0 => WinSCP 5.18 RC downloaded 4 May 2021

Thanks in advance.

Reply with quote

martin
Site Admin
martin avatar

Re: Here is how I register it.

Don't you get blocked somehow? I see in the log, that first time, the connection succeeds. But the second connection one second later hangs. Maybe the server does not like this. Why are you doing the fingerprint scan? Are you implementing a host key cache?

Reply with quote

ToniJ
Guest

If I run it from a windows service, it hangs.

First of all, thanks for your reply.

I assign the property mySessionOptions.SshHostKeyFingerprint because if I don't, we get error:
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set.
So, since I am going to connect with different Servers, what I do is request it with mySession.ScanFingerprint(mySessionOptions, "SHA-256") and assign mySessionOptions.SshHostKeyFingerprint before executing mySession.Open mySessionOptions.

From your words, I understand that we can connect without the need for set SshHostKeyFingerprint, but then how?

Thanks a lot.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
35,731
Location:
Prague, Czechia

Re: If I run it from a windows service, it hangs.

If you are calling the Session.ScanFingerprint for each and every connection, you are only ineffectively doing the same what you can achieve by setting SessionOptions.GiveUpSecurityAndAcceptAnySshHostKey
https://winscp.net/eng/docs/library_sessionoptions#giveupsecurityandacceptanysshhostkey
What is a security flaw.
Instead, the host key should be part of your session settings for each of your servers, along with the hostname and credentials.
See also https://winscp.net/eng/docs/faq_hostkey
For an alternative approach, see https://winscp.net/eng/docs/library_example_known_hosts
Or use the WinsCP 5.18 with its SshHostKeyPolicy.AcceptNew.

Reply with quote

Advertisement

ToniJ
Guest

If I run it from a windows service, it hangs.

Thanks Martin,

I have made the test of assigning the SshHostKeyFingerprint with the rest of credentials (without scan it).
To check, executing normaly, it works.
But from Windows Service, it also hangs at the same point.

I don't have any antivirus or firewall that can block the connection.

I have tested on another computer, the same thing happens.

Any ideas ?

Thanks

Reply with quote

ToniJ
Guest

If I run it from a windows service, it hangs.

I attach logs of other computer.
- assigning the SshHostKeyFingerprint with the rest of credentials (without scan it). -

Thanks Martin
  • WinSCP[DebugLogPath][Servicio].log (25.77 KB, Private file)
  • WinSCP[SessionLogPath][Servicio].log (5.55 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
35,731
Location:
Prague, Czechia

Re: If I run it from a windows service, it hangs.

Can you post log file when "executing normally"?

Does the service have a network connectivity?
(btw, your previous logs used a different local account and different IPs, so it's difficult to compare them)

Reply with quote

Advertisement

You can post new topics in this forum