Skip to main content
Participant
September 27, 2022
Question

CFIMAP running very slowly since Java Update

  • September 27, 2022
  • 2 replies
  • 351 views

We have a scheduled task that scrubs an inbox regularly and has been running like clockwork since January 2022. This sunday our IT team updated the JDK to 11.0.6 and it started timing out. I've cut the task down to the bare bones and is it still taking multiple minutes to load a single email. I wanted to know if anyone else is experiencing anything like this.

 

Our CF version: 2018.0.14.330003

The pared down code for the scheduled task:

<cfparam name="url.folder" default="inbox"/>
<cfparam name="url.maxrows" default="10"/>
<cfparam name="url.startRow" default="1"/>
<cftry>

	<cfset local.email_username = [USER_NAME] />
	<cfset local.email_password = [USER_PASS] />

	<cfimap  
		action="open"
	        server="imap.gmail.com"
		port="993"
		username="#local.email_username#"
		password="#local.email_password#"
		secure="yes" 
	        connection = "test.cf.gmail" />

	<!--- get all messages from IMAP server --->
	<cfimap
		action="getAll"
		maxrows="#url.maxrows#"
		startRow="#url.startRow#"
		name="emails"
		folder="#url.folder#"
		connection="test.cf.gmail" />

	<cfdump var="#emails#" />

	<cfcatch>
		<cfdump var="#cfcatch#" />
	</cfcatch>
</cftry>

<cftry>
<!--- close the connection --->
	<cfimap
		action="close"
		connection="test.cf.gmail" />

	<cfcatch>
		<cfdump var="#cfcatch#" />
	</cfcatch>
</cftry>

 

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    October 5, 2022

    Hi @jeffreyk34520003 ,

    How long does your code take?

    To measure the execution time, you could place the line

     

    <cfset startTime=getTickCount()>

     

    at the beginning, and the following line at the end

     

    <!--- Store mail-fetch times in mailFetchTimes.html within current folder. ---> 
    <cfdump var="#getTickCount()-startTime#" label="Total time to get mail" format="html" output="#expandPath('mailFetchTimes.html')#">

     

     I ran your code on ColdFusion 2018.0.14 + JDK11.0.16, changing just the values for username and password. It took consistently 7 seconds to fetch the mail. 

    BKBK
    Community Expert
    Community Expert
    October 5, 2022

    Some suggestions:

    1. Make sure that the JDK that your IT team installed is actually the one ColdFusion is using. Verify the java.home value in /bin/jvm.config.
    2.  Check the contents of /bin/jvm.config to ensure that TLS 1.x is not allowed (one of the many suggestions in the link Charlie has provided)
    3.  Open CMD (assuming Windows) on the server on which CF is running, and run the DOS command ping -a imap.gmail.com

    Make sure the connection to the gmail server is not impeded in anyway.

    Charlie Arehart
    Community Expert
    Community Expert
    September 28, 2022

    There's not any known issue (that I know of) about that combo, if you're wondering first about that.

     

    But you say you're running 11.0.6. Did you really mean that? Or 11.0.16 (released in July?) If not the latter, have you considered updating your jvm?

     

    Since you're using "secure" for the cfimap, this could indeed be a JVM (rather than a cf) problem. See this post of mine on the matter:

     

    https://coldfusion.adobe.com/2019/06/error-calling-cf-via-https-solved-updating-jvm/

     

    Let us know if it helps or not. 

    /Charlie (troubleshooter, carehart. org)
    Charlie Arehart
    Community Expert
    Community Expert
    October 1, 2022

    Jeffrey, any update? 

    /Charlie (troubleshooter, carehart. org)