• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

SMS Gateway Instance Won't Start on New CF21 Install

Explorer ,
Sep 28, 2022 Sep 28, 2022

Copy link to clipboard

Copied

Hello,

I am wondering if anyone could point me in the right direction. I am moving to a new Windows server and upgrading from CF2016 to CF2021, and I can't seem to get my SMS gateway running even though it works fine on the old server.

 

The errors I am getting in my coldfusion-out log when it attempts to start the instance are:
"SMSGateway (SMSWatch) Binding to SMSC"
"SMSGateway (SMSWatch) Bind operation failed: java.lang.NullPointerException"


This is the code for the CFC I am using for my instance. I am not sure where it originally came from, but probably from a ColdFusion example:

<cfcomponent>

	<cfset undeliverablePath = "C:\CF21\cfusion\sms\undeliverable" />
	
	<cffunction name="send" output="false" access="private" returntype="boolean">
		<cfargument name="username" required="true" type="string"/>
		<cfargument name="password" required="true" type="string"/>
		<cfargument name="from" required="true" type="string"/>
		<cfargument name="to" required="true" type="string"/>
		<cfargument name="body" required="true" type="string"/>
		
		<cftry>
			<!--- SMS can only be 160 characters. If SMS is longer than 160, break into multiple SMS's --->
			<cfset smsArray = arraynew(1)/>
			<cfset smsstr = ""/>
			<cfloop from="1" to="#len(arguments.body)#" index="i">
				<cfset smsstr = smsstr & mid(arguments.body, i, 1)/>
				
				<cfif i mod 160 eq 0>
					<cfset arrayappend(smsArray, smsstr)/>
					<cfset smsstr = ""/>
				</cfif>
			</cfloop>
			
			<cfif len(smsstr)>
				<cfset arrayappend(smsArray, smsstr)/>
			</cfif>
			
			<cfset urlstr = "https://api.twilio.com/2010-04-01/Accounts/#arguments.username#/SMS/Messages.xml"/>
			<cfloop from="1" to="#arraylen(smsArray)#" index="i">
				<cfhttp url="#urlstr#" method="post" username="#arguments.username#" password="#arguments.password#">
					<cfhttpparam type="formfield" name="From" value="#arguments.from#"/>
					<cfhttpparam type="formfield" name="To" value="#arguments.to#"/>
					<cfhttpparam type="formfield" name="Body" value="#smsArray[i]#"/>
				</cfhttp>
				
				<cfif listfirst(cfhttp.statusCode, " ") eq 200>
					<cflog file="sms-watcher-sent" text="from=#arguments.from#, to=#arguments.to#, body=#arguments.body#" />
					<cfreturn true/>
				<cfelse>
					<cfset twilXml = xmlparse(cfhttp.filecontent)/>
					<cflog file="sms-watcher-sent" text="error=#twilXml.TwilioResponse.RestException.Message.xmltext#" />
					<cfreturn false/>
				</cfif>
			</cfloop>
			
			<cfcatch type="any">
				<cflog file="sms-watcher" text="#cfcatch.message#" />
				<cfreturn false/>
			</cfcatch>
		</cftry>
	</cffunction>
	
 	<cffunction name="onAdd" access="public" output="false" returntype="void">
	 	<cfargument name="CFEvent" type="struct" required="yes">
		 
		 <cftry>
			<cffile action="read" file="#arguments.cfevent.data.filename#" variable="ddx" />
			<cfwddx action="wddx2cfml" input="#ddx#" output="smsStruct" />
			 
			<cfset fileName = getfilefrompath(arguments.cfevent.data.filename)/>
			<cfset folderName = getdirectoryfrompath(arguments.cfevent.data.filename)/>
			
			<cffile action="move" destination="#folderName#\#listfirst(fileName, ".")#.proc" source="#arguments.cfevent.data.filename#" />
			<cfset bSend = send(smsStruct.username, smsStruct.password, smsStruct.from, smsStruct.to, smsStruct.body)/>
			
			<cfif bSend>
	 			<cffile action="delete" file="#folderName#\#listfirst(fileName, ".")#.proc" />
			<cfelse>
				<cffile action="move" destination="#undeliverablePath#\#listfirst(fileName, ".")#.sms" source="#folderName#\#listfirst(fileName, ".")#.proc" />
			</cfif>
			
			<cfcatch type="any">
				  <cflog file="sms-watcher" text="#cfcatch.message#" />
				  <cffile action="move" destination="#undeliverablePath#\#listfirst(fileName, ".")#.sms" source="#folderName#\#listfirst(fileName, ".")#.proc" />
			</cfcatch>
		 </cftry>
    </cffunction>
 
    <cffunction name="onChange" access="public" output="false" returntype="void">
    </cffunction>
 
    <cffunction name="onDelete" access="public" output="false" returntype="void">
    </cffunction>
</cfcomponent>

 and here is the Config file:

directory=C:\CF21\cfusion\sms\spool
recurse=no
extensions=sms
interval=15000
addFunction=onAdd
changeFunction=onChange
deleteFunction=onDelete

 I feel clueless on this one, so it may be something obvious. Thank you in advance!

TOPICS
Advanced techniques , Event gateways

Views

146

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 28, 2022 Sep 28, 2022

How did you get this to work in an earlier version. What steps did you follow in writing and configuring the CFC and the configuration file? Please share the steps in detail to help us understand.

 

I ask because your CFC is different from what I would expect. For example, it contains no onIncomingMessage method. In addition, your config file is different from the sample that ships with ColdFusion, C:\ColdFusion2021\cfusion\gateway\config\sms-test.cfg

Votes

Translate

Translate
Community Expert ,
Sep 28, 2022 Sep 28, 2022

Copy link to clipboard

Copied

How did you get this to work in an earlier version. What steps did you follow in writing and configuring the CFC and the configuration file? Please share the steps in detail to help us understand.

 

I ask because your CFC is different from what I would expect. For example, it contains no onIncomingMessage method. In addition, your config file is different from the sample that ships with ColdFusion, C:\ColdFusion2021\cfusion\gateway\config\sms-test.cfg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 28, 2022 Sep 28, 2022

Copy link to clipboard

Copied

Thanks BKBK. You gave me the clue to find the file I needed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

LATEST

No problem. Feel free to open any further discussions on the subject. 🙂 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation