I had a problem with an application in coldfusion 9 and application.cfc.
In the onRequestStart method there were variables with application scope example:
<cffunction name = "onRequestStart">
<cfset application.URL_Images =
'<img src = "http: // # server_name #: # server_port # / aseng / images / logo1.jpg">'>
</cffunction>
As I have many people accessing the application, the server gave a timeout and I saw in the Monitor that the scope application was consuming a lot of memory.
The question is, do application scope variables in Application.cfc consume more memory than in Application.cfm?
In Application.cfm the server didn't happen to crash.
I have variables that need to be validated for each request because they receive different values depending on the type of access. We have remote access and local access which are separate ports.
How can I set these variables without consuming memory on the server?
To work around the problem, I went back to Application.cfm until I was sure that Application.cfc was created correctly.
Thanks
Do application scope variables in Application.cfc consume more memory than in Application.cfm
Answer: No. Not at all.
You may be setting things into the application scope that shouldn't be. That code says that for all users, for each request, redefine an application level variable. Seems like that value should be a request level variable as it changes based on the user and their settings.
User 1 starts a request and sets the value of application.URL_Images.
User 2 starts a request and sets the value of application.URL_Images.
User 1 completes their request and reads the value of application.URL_Images, which has now been changed.
User 2 completes their request and everything's ok.
User 1 wonders why they are seeing the wring logo.
It may just be the case that your application load is reaching current resource limits. Odd that it's only acting oddly with the cfc and not the cfm.
Check on your JDK version and make sure it's the latest supported by CF 9
Verify that you have enough memory allocated to your application instances.
Finally, review how you structured your Applicaiton.cfc. There may be something else in there overloading the application scope based on the CFC function triggers that is running under a different condition in the CFM. I would explore more of what else is in the application scope and ensure what is there, when it is loaded and if it needs to be "cached" there.
Related
Overview
I wish to collect the contents of a browser's address bar opened by a function in a program in C / C++. There are a few threads here which discuss the matter. However, none seems to be helpful to me.
My environment
OS : Windows 7, Windows 10.
Development language : C / C++
My project
I am writing an app in which I need to collect data from a server. The server requires the client to authenticate itself and uses the 2-step OAuth 2.0 protocol for that. I need to make use of a web API developed by a third party.
The following page describes the whole process.
https://apidocs.getresponse.com/v3/case-study/oauth2-authorization-code
However, I only have a problem with the first step : obtain an authorization code from the server.
A highlight from this page explains the process for the first step, the only one that matters here :
Want to see by yourself ? Try this.
I have created an account and registered a bogus app on getresponse.com for testing purpose.
Navigate to the following URL :
https://app.getresponse.com/oauth2_authorize.html?response_type=code&client_id=41979979-c18b-11ea-bb1c-00163ec8ce26&state=xyz
Login with :
Your email : jnj54972#cuoly.com
Password : #Aa11111
On the next screen, Click Yes.
After redirection to the example.com site, the next screen shows the following in the address bar :
http://example.com/receiver?code=<code>&state=xyz
This code in the address bar is precisely what I need to continue with the second step of the authentication when this page is displayed in the browser. Hence the necessity to collect the data contained in the address bar.
You can repeat the operation and navigate again to the same URL: you will not have to login again, and you will obtain another authorization code.
(Note : To test the Oauth 2.0 protocol on getresponse.com, I created an app on 9 July 2020. This account has a validity of 30 days. Therefore, the login credentials mentioned above are likely to expire a month after the date of creation.)
What I have tried so far
I won't go in details or this post may get too long. But I did try numerous 'curl GET' requests with various parameters. No luck : I never get the browser's address bar data with the code in return.
Can someone help ?
Here is a list of ways you could use to accomplish your task:
Hook a function that changes the address bar text in the browser. This can be achieved using remote dll/code injection and have the injected code send back the results to your main process by using shared memory or other interprocess communications methods
Get the memory address of the buffer holding the address bar text (memory scanners such as CE) then actively scan for changes in that address for your desired text which in this case is code=
Create a browser extension that listens for url change events in tabs and have it send the results back to your process using sockets preferably
I have a Django view which needs can be cached, however it needs to be recycled every 100th time when the view is called by the HTTP request.
I cannot use the interval based caching here since the number will keep changing upon traffic.
How would I implement this? Are there other nice methods around except maintaining a counter (in db) ?
Here are some ideas / feedback:
You're going to have to centralize something if you need it to be exact - the Redis idea in this linked solution looks OK if you can't put it in the main DB. If Redis is in your stack, I'd use that. If the 100 requests can be per user and you're using sessions, you could attach a counter to the session.
implementing a counter that counts requests with django
To not centralize the counter outside of the webserver would mean your app needs to be and stay single-threaded to keep counts in memory. It would also reset if the server was restarted. Not a great idea IMO...
If you really can't make it work with anything else, you could hack something like a request counter on your load balancer (...if the load balancer is a single machine you control, and you're comfortable doing that) and pass it as a header for Django to read.
We’ve come across this question fairly often at Load Impact, so I’m adding it to the Stack Overflow community to make it easier to find
Q: When performing a Load Impact load test, I need to have the VUs send cookies with their requests. How do I set a cookie for a VU?
Load Impact VUs will automatically save and use cookies sent to them by the server (through the "Set-Cookie:" header). When the user scenario executed by the VU ends and gets restarted (i.e. starts a new user scenario script iteration), cookies stored by the VU/client will be cleared.
Cookies, or more specifically the “Cookie:” header, is currently the only header that is set automatically by the client. Other headers, such as e.g. “If-Modified-Since:” will not be set unless the user specifies it in the load script (this is why caching is not emulated automatically - client caching behaviour has to be programmed).
You can't manipulate the stored cookies that the VU client has, but you can override or set a cookie used by the client if you specify the "Cookie:" header in the requests you make, like this:
http.request_batch({
{"GET", "http://example.com/", headers={["Cookie"]="name=value"}}
})
Although easily done from my perspective with IIS, I'm a total noob to Tomcat and have no idea how to set static values for cookie contents. Yes I've read the security implications and eventually will access via SSL so I'm not concerned. Plus I've read the Servlet 3.0 spec about not changing the value and I accept that.
In IIS I would simply set a HTTP Header named Set-Cookie with an arbitrary setting of WebServerSID and a value of 1001.
Then in the load balancer VIP containing this group of real servers, set the value WebServerSID at the VIP level, and for the first web server a cookie value of 1001 and so one for the remaining machines 1002 for server 2, 1003 for server 3.
This achieves session affinity via cookies until the client closes the browser.
How can this be done with Tomcat 7.0.22?
I see a great deal of configuration changes have occurred between Tomcat 6.x and 7.x with regard to cookies and how they're set up. I've tried the following after extensive research
over the last week.
In web.xml: (this will disable URL rewriting under Tomcat 7.x)
<tracking-mode>COOKIE</tracking-mode> under the default session element
In context.xml: (cookies is true by default but I was explicit as I can't get it working)
cookies=true
sessionCookiePath=/
sessionCookieName=WebServerSID
sessionCookieName=1001
I have 2 entries in context.xml for sessionCookieName because the equivalent commands from Tomcat 6.x look like they've been merged into 1.
See http://tomcat.apache.org/migration-7.html#Tomcat_7.0.x_configuration_file_differences
Extract:
org.apache.catalina.SESSION_COOKIE_NAME system property: This has been removed. An equivalent effect can be obtained by configuring the sessionCookieName attribute for the global context.xml (in CATALINA_BASE/conf/context.xml).
org.apache.catalina.SESSION_PARAMETER_NAME system property: This has been removed. An equivalent effect can be obtained by configuring the sessionCookieName attribute for the global context.xml (in CATALINA_BASE/conf/context.xml).
If this is not right then I simply do not understand the syntax that is required and I cannot find anywhere that will simply spell it out in plain black and white.
Under Tomcat 6.x, I would have used Java Options in the config like:
-Dorg.apache.catalina.SESSION_COOKIE_NAME=WebServerSID
-Dorg.apache.catalina.SESSION_PARAMETER_NAME=1001
The application I'm using does not have any of these values set elsewhere so it's not the application.
All these settings are in context/web/server.xml files at the Catalina base
At the end of the day what I need to see in the response headers under Set-Cookies: (as seen using Fiddler) is:
WebServerSID=1001
NOT
JSESSIONID=as8sd9787ksjds9d8sdjks89s898
thanks in advance
regards
The best you can do purely with configuration is to set the jvmRoute attribute of the Engine which will add the constant value to the end of the session ID. Most load-balancers can handle that. It would look like:
JSESSIONID=as8sd9787ksjds9d8sdjks89s898.route1
If that isn't good enough and you need WebServerSID=1001 you'll have to write a ServletFilter and configure that to add the header on every response.
I apologize if this is a "duh" question. It seems like the answer should be easily googleable, but I haven't found it yet.
I am working on a large Coldfusion application that stores a large amount of session/user data in the Client scope (ie <cfset Client.UserName = "JoshuaC"> ). I did not write this application, and I don't have the luxury of significantly refactoring it.
I've been given the task of setting the Client variables to time out after 72 hours. I'm not entirely sure how to do this. If I had written the application, I would have stored the variables in the Session scope, and then changed the sessiontimeout attribute of the CFAPPLICATION tag. As it is though, I'm not sure if that timeout affects the Client variables, or what their level of persistence is. The way the application works now, the Client variables never time out, and only clearing the user's cookies, or visiting a logout page which sets all the Client-scoped application variables to "", will clear the values.
Of course, I could create some kind of timestamp variable like Client.LastAccessDateTime, and put something in the Application.cfm to clear the client variables if that datetime is more than 72 hours prior to Now(). But there's got to be a better way, right?
Depending whether your are using a datasource or registry as a Client Store you have to set the "Purge data for clients that remain unvisited for 90 days to 3 days (=72 hours) on the
ColdFusion Administrator => Client Variables => Registry
or
Client Variables => NameOfDatabase Page.
If Client Variables are stored as cookies, then you have to adjust the expires period, when setting the cookie.
The Purge Interval on the Client Variables page only controls how often ColdFusion executes a purge operation on your client stores (= seeks for expired Client Variables in order to delete them).
I suppose you are looking for Purge Interval setting, which is configured in CF Administrator at Server Settings > Client Variables page. Default interval is 1 hour 7 min.
EDIT: This setting value is not exactly what you need. I'm sorry, see my comment about purging -- think it is more accurate.