No announcement yet.

SFTP Polling

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    You said two channels were stuck, are there stacktraces for the other channel as well?
    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.


    • #17
      I updated the previous post to include them. I searched the entire thread dump for both locks being waited on (0x00000000f3478968 and 0x00000000f346b0e8) and they don't appear anywhere else in the dump.
      Last edited by agermano; 02-28-2018, 06:58 AM.


      • #18
        Both are stuck again According to the Connection Log one of themhas missed the last 8 pollings, and the other has only missed 1. They both poll hourly. Is there any additional information I can provide?

        I haven't said this yet, but both channels connect to the same sftp server, but pull different files. Not sure if that is relevant.


        • #19
          Mystery solved:


          • #20
            Until I'm able to upgrade to 3.6, I deployed a workaround, and it seems to be working. Between the 2 channels that keep getting stuck, it's done 9 bounces since early Monday morning, and I haven't had to touch it.

            I configured a channel called "File Reader Bouncer." It generates a message any time it attempts to bounce a channel. All inbound/outbound types should be Raw. Message storage can be set to metadata, as the messages are blank, but it stores the channel being bounced in the SOURCE and the status in the TYPE. Here is the Javascript Reader code that I have running every 5 minutes:

            // adjust these values for your needs
            const channelsToMonitor = [
            const maxPoolActive = 6;
            const maxStopTimeoutInMillis = 10000;
            const maxHaltTimeoutInMillis = 10000;
            const maxStartTimeoutInMillis = 10000;
                Possible values for mirth_type: 
            var targetChannelId, channel, sourceConnector, f, fileConnector, pools, pool, future, isStopped, mirth_type, isInterrupted = false;
            function wait(future, timeout) {
                catch(e if e.javaException instanceof java.lang.InterruptedException) {
                    isInterrupted = true;
                catch(e) {}
                return future.isDone();
            var messages = new java.util.ArrayList();
            var donkey = com.mirth.connect.donkey.server.Donkey.getInstance();
            for (var i = 0; i < channelsToMonitor.length; i++) {
                if (isInterrupted || java.lang.Thread.currentThread().isInterrupted()) break;
                targetChannelId = channelsToMonitor[i];
                channel = donkey.getDeployedChannels().get(targetChannelId);
                if (!channel) continue;
                sourceConnector = channel.getSourceConnector();
                f = sourceConnector.getClass().getDeclaredField("fileConnector");
                fileConnector = f.get(sourceConnector);
                f = fileConnector.getClass().getDeclaredField("pools");
                pools = f.get(fileConnector);
                try {
                    // can cause an issue if channel is deployed, but stopped
                    pool = pools.values().iterator().next();
                catch(e) {
                // pool is the channel's source connector's pool of FileSystemConnection objects.
                // The default max objects for the pool is 8.
                // We can set maxPoolActive to be lower than 8 to bump the channel before it freezes.
                // Make sure to set maxStopTimeoutInMillis appropriately in this case to avoid halting a
                // channel while it is actively working.
                if (pool.getNumActive() > maxPoolActive || (pool.getNumActive() == 8 && pool.getNumWaiters() == 1)) {
                    future = ChannelUtil.stopChannel(targetChannelId);
                    isStopped = wait(future, maxStopTimeoutInMillis);
                    if (!isStopped) {
                        future = ChannelUtil.haltChannel(targetChannelId);
                        isStopped = wait(future, maxHaltTimeoutInMillis);
                    if (isStopped) {
                        future = ChannelUtil.startChannel(targetChannelId);
                        if (!wait(future, maxStartTimeoutInMillis)) {
                            mirth_type = "FAILED_START";
                        else {
                            mirth_type = "RESTARTED";
                    else {
                        mirth_type = "FAILED_HALT";
                    messages.add(new RawMessage('', null, {mirth_source: targetChannelId, mirth_type: mirth_type}));
            return messages;


            • #21
              FSTP After processing action run with out processing

              I faced a problem when I using SFTP file reader and after processing Action, I move the processed file to another folder called 'Processed', sometimes the after processing action run without the file is processed and even the channel log doesn't tell me anything about the processed file, and suddenly I find the file in the processed folder, anyone face that problem before, any advice?!!