ColdBoxBE, CB Remote Proxy and Railo Gateways

Has anyone experienced oddities with remote proxies while using Railo gateways? I can’t tell if I’m crazy and I’m configuring the application wrong or there is a bug. I’ll try not to make this post too long.

In my very basic test, using Railo’s WebSocket:

  1. I create a Railo site/context
  2. Create a very simple CB application with a remote proxy, inside the proxy I use announceInterception inside every method (onClientOpen,onClientClose,onMessage)
  3. I do not init the application by pointing my browser to it
  4. Inside the Railo admin, I create mappings to the application, create the WebSocket gateway, point the listener to the CB remote proxy in Step 2
  5. Try to start the gateway.

Right off the bat this happens (line #55 of Application.cfc is onApplicationStart()):

invalid component definition, can’t find component [railo.extension.gateway.config.Coldbox];

at system.web.config.applicationloader_cfc$cf.udfCall1(/coldbox/system/web/config/ApplicationLoader.cfc:76):76
at system.web.config.applicationloader_cfc$cf.udfCall(/coldbox/system/web/config/ApplicationLoader.cfc):-1
at system.web.services.loaderservice_cfc$cf.udfCall(/coldbox/system/web/services/LoaderService.cfc:28):28

at system.bootstrap_cfc$cf.udfCall1(/coldbox/system/Bootstrap.cfc:71):71
at system.bootstrap_cfc$cf.udfCall(/coldbox/system/Bootstrap.cfc):-1
at application_cfc$cf.udfCall(/Application.cfc:55):55

at admin.services_gateway_cfm414$cf.call(/railo-context-compiled/admin/services.gateway.cfm:13):13

The gateway tries to init the application, the application tries to bootstrap coldbox, then the application fails to find my apps Coldbox.cfc config. If I understand the underlying cause correctly this means the context it’s running in is Not in my applications root directly, but instead /railo/extensioin/gateway/. I tried to fix this by using COLDBOX_CONFIG_FILE which ‘seemed’ to have some effect, but not enough.

After changing COLDBOX_CONFIG_FILE to “mymapping.config.Coldbox”, the same thing pretty much happened but instead for the Cachebox config:

invalid component definition, can’t find component [railo.extension.gateway.config.CacheBox];
at system.cache.config.cacheboxconfig_cfc$cf.udfCall1(/var/www/ColdBoxBE/system/cache/config/CacheBoxConfig.cfc:47):47
at system.cache.config.cacheboxconfig_cfc$cf.udfCall(/var/www/ColdBoxBE/system/cache/config/CacheBoxConfig.cfc):-1
at system.web.services.loaderservice_cfc$cf.udfCall(/var/www/ColdBoxBE/system/web/services/LoaderService.cfc:144):144
at system.web.services.loaderservice_cfc$cf.udfCall(/var/www/ColdBoxBE/system/web/services/LoaderService.cfc:48):48
at system.bootstrap_cfc$cf.udfCall1(/var/www/ColdBoxBE/system/Bootstrap.cfc:71):71
at system.bootstrap_cfc$cf.udfCall(/var/www/ColdBoxBE/system/Bootstrap.cfc):-1
at application_cfc$cf.udfCall(/var/www/network.sigmaprojects.org/Application.cfc:56):56

This was harder to ‘fix’ since there is no config option in plain sight. Since my Coldbox.cfc config was working, I created a key called Cachebox and duplicated what it expected (since the LoaderService calls controller.getSetting(“cacheBox”), I can explicitly set it)

Then that got ‘fixed’, but the same thing happened again for Wirebox.

Now before anyone says the obvious “If you start the application via a http get and it works, make sure to do that”… There are a slew of different problems that come up when the Application times out.

Long story short:
Am I missing a config option somewhere to let the application know what context/directory it’s supposed to run in when starting the application from a CB remote proxy request?

Have you set the COLDBOX_APP_ROOT_PATH and COLDBOX_APP_MAPPING settings. In theory, if they’re correct everything else should work, including the config. The COLDBOX_CONFIG_FILE setting is only needed if you stored your config in a non-standard location.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

COLDBOX_APP_ROOT_PATH seems to have no effect…
COLDBOX_APP_MAPPING Does work and the gateway and application seem to start correctly… other problems pop up, setBaseURL will be off because cgi.http_host will be wrong when started from a gateway, and because AppMapping is defined it’ll be even more wrong.

But once this is all manually set, things seem to work for a while until…
application inactivity, waited an hour and tried to communicate to the gateway through the proxy, the gateway status is listed as “failed”. This is the error in the log:

The coldbox main controller has not been initialized;ColdBox Controller Not Found
at system.remote.coldboxproxy_cfc$cf.udfCall1(/coldbox/system/remote/ColdboxProxy.cfc:218):218
at system.remote.coldboxproxy_cfc$cf.udfCall1(/coldbox/system/remote/ColdboxProxy.cfc:230):230
at system.remote.coldboxproxy_cfc$cf.udfCall1(/coldbox/system/remote/ColdboxProxy.cfc:182):182
at modules.websocket.remote.websocketlistener_cfc$cf.udfCall(/var/www/network.sigmaprojects.org/modules/websocket/remote/WebSocketListener.cfc:12):12
at railo.extension.gateway.websocket_cfc$cf.udfCall(/var/www/network.sigmaprojects.org/WEB-INF/railo/components/railo/extension/gateway/WebSocket.cfc:105):105

At this point it’s fatal. A fwreinit will not save it. Only course of action to get the gateway and CB talking to each other again is to rename the CB Application name, remove the gateway and re-create it.

Hm, I wonder if that is a Railo bug failing to call onApplicationStart when the application times out. I thought we even had reload checks in onRequestStart though that would restart the application after a timeout.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Well, the boostrap does have a call to reloadChecks() in onRequestStart.
I tested to be sure the gateway does in fact notify App.onRequestStart(), the targetPage argument is /railo/extension/gateway/WebSocket.cfc

Inside Bootstrap’s onRequestStart is:
if( findNoCase( ‘index.cfm’, listLast( arguments.targetPage, ‘/’ ) ) ){
processColdBoxRequest();
}
Well, the target page for a gateway does not contain index.cfm. I’m not as intimate with CB as you may be, so do you think this may cause a problem?

That could be an issue. You only really need that I check I think if you’re going to have legacy .cfm pages like /products.cfm that you want to work without firing off ColdBox.

If you know non-coldbox requests (including proxies) are going to need ColdBox, you can run the reload checks on them. It looks like the ColdBox proxy checks to see if ColdBox is there, but it only throws an error if it’s not (which is the error you were seeing). The base proxy class does have a loadColdBox() method which will make sure it’s loaded.

I’m honestly not sure off the top of my head what the expected procedure is for that, as far as when you should have to call that. I’m kind of surprised the loadColdbox() method isn’t automatically called form the verifyColdBox() method.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Aye, the base proxy class does have an loadColdbox() but… it’s marked Private and I can’t find if it’s ever called… oversight?

I’m running into the same problem - setting COLDBOX_APP_MAPPING = “/” gets around the problem and allows everything to start - however, as soon as my gateway component receives a message, I’m seeing: “ColdBox Controller Not Found” - although my APP has been initialized.

Were you able to get around this issue?

Many Thanks,

-sT

Hey Guys,

I must be missing something - when the WebSocketListener (in the module of my app) is called from the Gateway when a message is received, the application scope belongs to lucee_context and not my application. So when announceInterception is called in my listener cfc which extends ColdBoxProxy, ColdboxProxy’s verifyColdBox() throws the error: “ColdBox Controller Not Found”

How can I get around this - how can I force my listener cfc to use the app scope of my application and not of the gateway?

Many Thanks,

-sT

Ah, for Railo/Lucee in admin under Request / Application listener mode needs to be set to root - then the correct app scope is exposed to the listener.

-sT

Ahh interesting-- can you expound on that a little more so we can add it to the docs. I haven’t actually used Railo/Lucee gateways before so I’m not familiar with that setting. I didn’t know it was possible to hit a different application scope.

Thanks!

~Brad