【问题标题】:Communications failure link in CFC with query带有查询的 CFC 中的通信故障链接
【发布时间】:2011-07-13 15:30:57
【问题描述】:

我有一个 CFC,负责处理招聘网站上的“联系我们”类型的表单。 cfc 旨在处理来自站点的几种不同形式;一个通用的“联系我们”表单和另一个“我对此工作感兴趣”表单。

当 CFC 获取数据,并且职位发布的 ID# 包含在参数中时,CFC 会进行快速查询并获取职位发布信息,将其包含在电子邮件中并向 HR 部门和用户发送包含职位发布信息以及用户联系信息的电子邮件。

如果未检测到 ID,CFC 只会向用户发送一封确认电子邮件并将联系信息发送给 HR 部门。

处理通用(非 ID)表单后一切正常。但是,当需要处理包含快速查询的表单时,我收到一个错误:

Communications link failure The last packet successfully received from the server was 61,380 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.

为什么填充我的页面的查询可以正常工作,但此 CFC 会在其中引发查询错误?

我们在共享主机环境中使用 MYSQL 运行 CF9。

CFC...

<cfif len(local.data.job_id)>
        <cftry>
        <cfquery name="qJobsforEmail" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
            SELECT * FROM #local.data.table# WHERE #local.data.table#.#local.data.column#= <cfqueryparam value="#local.data.job_id#" cfsqltype="cf_sql_numeric">
        </cfquery>
        <cfcatch type="any">
            <cfmail to="my@email.com" from="server@host.com" subject="Error processing query" type="html">
            <h3>There was an error processing the query</h3>
            <p><cfoutput>#cfcatch.Detail#</cfoutput></p>
            <p><cfoutput>#cfcatch.NativeErrorCode#</cfoutput></p>
            <p><cfoutput>#cfcatch.SQLState#</cfoutput></p>
            <p><cfoutput>#cfcatch.Sql#</cfoutput></p>
            <p><cfoutput>#cfcatch.queryError#</cfoutput></p>
            <p><cfoutput>#cfcatch.where#</cfoutput></p>
            <p><cfoutput>#cfcatch.type#</cfoutput></p>
            <cfdump var="#local#">
            </cfmail>
            <cfset local.response["error"] = 'true'>
            <cfset local.response["message"] = 'Error message to the page goes here...'>
            <cfreturn local.response>
            <cfabort>
        </cfcatch>
        </cftry>
        <cftry>
        <cfmail to="#local.data.email#" bcc="hr@theclient.com"  from="server@host.com" subject="Thank you for contacting us" type="html">
        <h2>We&rsquo;re glad you contacted us.</h2>
        <p>Warm and fuzzy thank you message here</p>
        <p>We received the following information on <cfoutput>#DateFormat(Now())#</cfoutput>, <cfoutput>#TimeFormat(Now())#</cfoutput>: </p>
        <p>First Name: <cfoutput>#local.data.first_name#</cfoutput></p>
        <p>Last Name: <cfoutput>#local.data.last_name#</cfoutput></p>
        <cfif len(local.data.suffix)>
            <p>Suffix: <cfoutput>#local.data.suffix#</cfoutput></p>
        </cfif>
        <p>Specialty: <cfoutput>#local.data.specialty#</cfoutput></p>
        <p>Email Address: <cfoutput>#local.data.email#</cfoutput></p>
        <p>Phone: <cfoutput>#local.data.phone#</cfoutput></p>
        <p> Current City and State: <cfoutput>#local.data.city#</cfoutput></p>
        <cfif len(local.data.comments)>
            <p>Message: <cfoutput>#local.data.comments#</cfoutput></p>
        </cfif>
        <p style="border-top:thin dotted black;padding-top:20px;font-weight:bold;">This is the position you&rsquo;re inquiring about:</p>
        <p style="font-weight:bold;"><cfoutput>#qJobsforEmail.title#</cfoutput></p>
        <p style="padding-bottom:20px;"><cfoutput>#qJobsforEmail.description#</cfoutput></p>
        <p>Our Recruiter will review this information and get in touch with you as soon as possible. Please make sure your email or phone number listed above is correct.</p>
        <p>Thanks again for contacting us. We look forward to speaking with you soon.</p>
        </cfmail>
        <cfcatch type="any">
            <cfmail to="my@email.com" from="server@host.com" subject="Error processing email" type="html">
            <h3>There was an error processing the email at</h3>
            <cfdump var="#cfcatch.Detail#">
            <cfdump var="#local#">
            </cfmail>
            <cfset local.response["error"] = 'true'>
            <cfset local.response["message"] = 'message to return to the page...'>
            <cfreturn local.response>
            <cfabort>
        </cfcatch>
        </cftry>

    <cfelse>

<!-- regular ol form process goes here -->
</cfif>

【问题讨论】:

    标签: mysql coldfusion cfc


    【解决方案1】:

    我认为这不是您的代码的问题,而是您的托管公司应该调查的问题。

    可能发生的情况是 ColdFusion 正在尝试从其连接池中重用数据库连接,但通信链接已断开。您通常可以通过向数据源设置添加验证查询(例如 SELECT 1)或禁用连接池来解决此问题。

    我必须感谢 Steven Erat 在这个特定问题上的知识:http://forums.adobe.com/message/3396333#3396333

    【讨论】:

    • +1 - 这不是代码错误,而是建议的 cf 服务器和数据库的配置。
    • 我喜欢这个地方。谢谢你。谢谢你。在我打电话给我的主人并要求他们调查之后,我将停止用头撞桌子并开始清理血液。
    • 此外,让 Pete Freitag 说“我认为你的代码没有问题”,就像是金戳验证。让我内心感到温暖和快乐。
    • +1 表示温暖愉快的评论 :) (.. 以及实际答案)
    猜你喜欢
    • 1970-01-01
    • 2012-05-27
    • 2021-11-21
    • 2012-09-20
    • 2018-02-17
    • 2012-10-14
    • 2011-08-12
    • 1970-01-01
    • 2021-08-09
    相关资源
    最近更新 更多