I have a big application, where I use cache.
I have alot of pages where my application only connect and disconnect to the database.
Is it possible? connect only when my model really need to fetch data from the database?
I made my connection into a bootstrap. If I remove it, my model can made connection automatic?
-- edited
I made the modify into Zend_Db_Adapter_Pdo_Abstract::_connect()
$debug = getenv("APPLICATION_DEBUG");
if($debug == 1) {
$log = "[" . date("H:i:s") . "] Initializing database connection";
Zend_Registry::get("debug")->Log($log);
}
And
//
if($debug == 1) {
$log = "[" . date("H:i:s") . "] Database connection initialized";
Zend_Registry::get("debug")->Log($log);
}
My debug method save an file into application/tmp/logs/debug. This method show all executed queries and time. When my page are in cache, any query are executed
Date: Sep 10 2013 10:38:12
Access From: ::1
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Filename: /media/backup/www/primeseven.com.br/library/Prime/Debug.php
Access URL: http://localhost/primeseven.com.br/
Referer: http://localhost/
Request method: GET
POST params:
===========================================
[10:38:12] Application initialized
[10:38:12] Initializing database connection
[10:38:12] Database connection initialized
===========================================
Total time: 1.339390039444
Queries: 0
Why you made db connection into bootstrap? Just try to use models and Zend_Db_Table_Abstract http://framework.zend.com/manual/1.12/en/learning.quickstart.create-model.html
The connection will be opened only by using the model.
Related
Every time I open my web app after a while, the first request always returns 504 Gateway Timeout error. However, the immediate subsequent request return data with status 200. This is true for almost every API route. The error log on vercel looks like:
GET] /api/villages?subdistrict=4231
12:14:52:06
Function Status: None
Edge Status: 504
Duration: 10010.66 ms
Init Duration: N/A
Memory Used: 118 MB
ID: rq8d4-1628059491869-fecd750a64de
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36 Edg/92.0.902.62
2021-08-04T06:45:02.214Z 10867116-4d89-4559-b976-14418b6f5102 Task timed out after 10.01 seconds
I first suspected that the error is with MongoDB connection, however it works just fine if I build the project on my local machine. The waiting period is always below 500ms.
I don't know how to solve or even diagnose this issue as the site is already in production, and the error occurs only when deployed on Vercel. Please help me solve the issue.
We have a site using Windows authentication sitting behind a firewall that we are accessing through ProxyPass. We then need to access an API application on the same server, but are receiving a 401 unauthorized error when using rewrite_proxy rules when we try to access it. How can we pass the credentials for authentication?
To perform the initial redirect from the secure serve to the internal application server:
In the https.conf file
ProxyPass /blastdev/ http://10.0.212.198/blastdev/
This seems to be working correctly and is loading the content on the page until we reach the api calls:
in the .htaccess file
RewriteCond %{REQUEST_URI} ^/blastdev/blast(.*)
RewriteHeader X-Remote-User: .* %{REMOTE_USER}
RewriteHeader X-Logon-User: .* %{LOGON_USER}
RewriteHeader AUTH_TYPE: .* %{AUTH_TYPE}
RewriteProxy ^/blast/(.*)$ http://10.0.212.198/blast/$1 [NC, A, CR]
simply to try to show any user information. All fields are showing blank though.
Here are the headers we are currently sending:
Headers:
'Cache-Control'='no-cache'
'Pragma'='no-cache'
'Expires'='Sat, 01 Jan 2000 00:00:00 GMT'
'Accept'='application/json, text/plain, */*'
'Accept-Encoding'='gzip, deflate'
'Accept-Language'='en-US,en;q=0.9'
'Referer'='http://dev.*******.com/blastdev/'
'User-Agent'='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
'X-REQUEST-URI'='/blastdev/blast/api/usermanager/'
'X-Rewrite-Url'='/blastdev/blast/api/usermanager/'
'X-Original-Url'='/blastdev/blast/api/usermanager/'
'X-logio_http_input_size'='0'
'X-logio_request_headers_size'='746'
'X-Remote-User'=''
'X-Logon-User'=''
'AUTH_TYPE'=''
'Max-Forwards'='10'
'X-Forwarded-Host'='dev.*******.com'
'X-Forwarded-For'='10.1.13.42'
'X-Forwarded-Server'='10.0.90.54'
We need to be able to access the current user if they are AD authenticated and see that they are anonymous if not.
Any additional assistance in tests we can run for further troubleshooting would also be appreciated.
I have a problem with reading a socket in PERL.
The story goes like this :
1.1.1.1 is my server
2.2.2.2 is my other server that it is opened as ssh tunnel on 1.1.1.1
3.3.3.3 is my ip from Mozilla Firefox
I have a ssh tunnel opened on port 12345 and a tcp.pl "server" that is oppenning on port 2000 and it is forwarding all raw traffic to port 12345 then gets it back again.
I have oppened Mozilla Firefox and put at SOCKS5 1.1.1.1:2000 (the tcp.pl server), and when i surf the web, i surf with 2.2.2.2's ip, witch is good.
I wrote someware in my code to print all sockets that tcp.pl is getting with this command :
`print $buffer;`
The problem is that i can read HTTP HEADERS and i see stuff like
GET / HTTP/1.1
Host: site.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: _ga=GA1.2.1235518067.1410367631
Connection: keep-alive
witch is ok, but i don't quite get the HTTP CONTENT , i mean i don't get the HTML code. I sometimes get a part of the HTML CODE LIKE THIS
:G�� ��� <-- some wired characters
<html>...</html>
���lOP� <-- some wired characters
and sometimes i get
PuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTy
and a beep sound.
the code (tcp.pl)
an infinite loop that reads reads and reads ....
while (1)
{
for my $socket ($ioset->can_read)
{
if($socket == $server)
{
new_connection($server);
}
else
{
next unless exists $socket_map{$socket};
my $remote = $socket_map{$socket};
my $buffer;
# get data from main port
my $read = $socket->sysread($buffer, 4096);
if ($read)
{
print $read; # gives a number like 43243 5436346456 34654643464
print $buffer; # allways gives HTTP headers, and token is frequently distorted, showing characters like ":G�� ������lOP�" and some chunks of HTML CODE from time to time
# sometimes i get output like "PuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTyPuTTy" and hearing some beeping sounds
# forward data to the other port (in browser you see no differance)
$remote->syswrite($buffer);
}
else {
close_connection($socket);
}
}
}
}
I believe this is because the fact that i don't order the packets properly, i mean i have to read SOCKETS and order by ACK and SEQ flags, then read it.
Now my main quession, how do i read the HTML content as it is?
Thank you.
My web app can successfully create fitness.runs for myself and friends, but not for test users (created in the Test Users view of the Roles tab of the App's Dashboard). So I have a problem getting the app approved in the review, required for explicit sharing.
The app makes the following HTTP request to create (line breaks in content for readability):
POST /me/fitness.runs HTTP/1.1
Content-Type: application/x-www-form-urlencoded
course=https%3A%2F%2Fbroker-web.appspot.com%2Fpub%2Fcourse%2FagxzfmJyb2tlci13ZWJyLAsSDERQYXJ0aWNpcGFudBiAgICA_fCfCgwLEgZEU3BsaXQYgICAgICAgAoM
&start_time=2014-04-30T13%3A43%3A46
&expires_in=86400
&object=%7B%22app_id%22%3A%22255653361131262%22%2C%22title%22%3A%22Demo+410m%22%7D
&access_token=ACCESS_TOKEN
The successful response contains the action id (for myself and friends), and for test users the following error message is returned:
HTTP 500 OK
{error={message=An unexpected error has occurred. Please retry your request later., type=OAuthException, code=2}}
The crawler was successful visiting the object:
89.236.16.14 - - [30/Apr/2014:06:45:13 -0700] "GET /pub/course/agxzfmJyb2tlci13ZWJyLAsSDERQYXJ0aWNpcGFudBiAgICA_fCfCgwLEgZEU3BsaXQYgICAgICAgAoM HTTP/1.1" 200 6211 -
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36"
"broker-web.appspot.com" ms=135 cpu_ms=41 cpm_usd=0.000694 app_engine_release=1.9.4 instance=00c61b117ce48a0349d573d3cd16b02587ffe00b
My app was using the wrong FB app ID when creating the action. That is an issue only for Test Users, as they exist for the correct FB App only.
Code
function radiotest(host,port)
local rstr="Online"
local sock, err = socket.tcp()
if not sock then
return "Failed"
end
sock:settimeout(1)
local res, err = sock:connect(host, port)
if not res then
return "offline"
else
sock:settimeout(1)
sock:send("GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status \r\n Accept: */*\r\n\r\n")
sock:settimeout(3)
local data=sock:receive('*a')
sock:close()
print(data)
-- Further processing content here
end
end
print( radiotest( "10.*.*.*", 1234 ) )
The above socket connection returns me:
ICY 404 Resource Not Found
icy-notice1:<BR>SHOUTcast Distributed Network Audio Server/win32 v1.9.7<BR>
icy-notice2:The resource requested was not found<BR>
I think the problem is in my headers listing, but I'm unable to trace it.
The page opens fine in all browsers(Opera does need to be masked as another browser; otherwise it just keeps on downloading all songs).
I've tried using following strings inside sock:send()
GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n
GET /index.html HTTP/1.0\r\n UserAgent: Opera/9.80 (Windows NT 6.1; Win64; x64) Presto/2.12.388 Version/12.12\r\n\r\n
GET /index.html HTTP/1.0\r\n UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17\r\n\r\n
I'm totally stuck at this part. How do I fetch the page using socket.tcp()?
After looking at your packet capture, it seems that what is actually getting sent over the wire is wrong. Your user-agent string isn't making it:
> GET /index.html HTTP/1.0
< ICY 404 Resource Not Found
< icy-notice1:<BR>SHOUTcast Distributed Network Audio Server/win32 v1.9.7<BR>
< icy-notice2:The resource requested was not found<BR>
If you don't specify a user-agent that contains Mozilla, you will be unable to access the admin interface, or any part of it. Go back and check your code again on what you're sending.
#Brad Thanks. Your help with Wireshark was indeed practicable. The User-Agent header was not being passed to the server because of an extra space I was providing in the request.
sock:send("GET /index.html HTTP/1.0\r\n UserAgent: SHOUTcast Song Status \r\n Accept: */*\r\n\r\n")
The \r\n UserAgent: SHOUTcast Song Status should instead be:
\r\nUser-Agent: SHOUTcast Song Status
And it is working fine now.
Thanks for the help. :D
The results from the function after filtering out the HTML is like:
Online(Tonic - If You Could Only See)
Online(Tonic - If You Could Only See) Stream is up at 256 kbps with 0 of 32 listeners (0 unique)