Announcement

Collapse
No announcement yet.

Sftp?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sftp?

    Our servers changed and no longer support FTP, only SFTP.

    Current mirth code says:
    var ftpConn = new Packages.com.mirth.connect.connectors.file.filesys tems.FtpConnection(etc....

    Can I change this to the following and will it work (can't find API docs):
    var ftpConn = new Packages.com.mirth.connect.connectors.file.filesys tems.SftpConnection(etc...

  • #2
    It wont be as easy as that :-)

    You will have to do something like this in Mirth

    https://stackoverflow.com/a/14830708

    They use the JSch library.
    HL7v2.7 Certified Control Specialist!

    Comment


    • #3
      Actually it is just as easy as that, no need to go directly to JSch unless you need to satisfy a very specific use-case...

      Code:
      var host = 'localhost';
      var port = 22;
      var username = 'user';
      var password = 'pass';
      var props = new com.mirth.connect.connectors.file.SftpSchemeProperties();
      var options = new com.mirth.connect.connectors.file.FileSystemConnectionOptions(username, password, props);
      var timeout = 10000;
      var sftpConn = new com.mirth.connect.connectors.file.filesystems.SftpConnection(host, port, options, timeout);
      
      try {
      	sftpConn.canRead('/');
      } finally {
      	sftpConn.destroy();
      }
      Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

      Nicholas Rupley
      Work: 949-237-6069
      Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


      - How do I foo?
      - You just bar.

      Comment


      • #4
        Is the host which you assigned "localhost" the ip address of the destination?

        That is kind of confusing, since it says localhost.

        Comment


        • #5
          Host can be an IP address too.

          Code:
          var host = '::1/128';
          var port = 22;
          var username = 'user';
          var password = 'pass';
          var props = new com.mirth.connect.connectors.file.SftpSchemeProperties();
          var options = new com.mirth.connect.connectors.file.FileSystemConnectionOptions(username, password, props);
          var timeout = 10000;
          var sftpConn = new com.mirth.connect.connectors.file.filesystems.SftpConnection(host, port, options, timeout);
          
          try {
          	sftpConn.canRead('/');
          } finally {
          	sftpConn.destroy();
          }
          Jon Bartels

          Zen is hiring!!!!
          http://consultzen.com/careers/
          Talented healthcare IT professionals wanted. Engineers to sales to management.
          Good benefits, great working environment, genuinely interesting work.

          Comment


          • #6
            not sure what '::1/128'; is?

            Comment


            • #7
              Confirmed Working

              The SFTP code above worked and 'localhost' is actually the remotehost you are trying to connect to.

              Comment

              Working...
              X