Comments (4)
Save the request instance before passing it for execution.
from yii2-httpclient.
I will tell you what I'm trying to achieve. There is some problem in closing database after some timeout, so I should do the trick:
Yii::$app->db->close();
Yii::$app->db->open();
I want to do this after every request via HttpClient if the response time bigger than some value (for example, 15 seconds).
It is the convenient way to do this on EVENT_AFTER_SEND, but for Response class or for Request class? Maybe, there is more simple way. I have no ability to change mysql timeout configs on server.
from yii2-httpclient.
$request = $client->get('http://test.com');
$response = $request->send();
$time = $request->requestTime();
if ($time > 2000) {
Yii::$app->db->close();
Yii::$app->db->open();
}
from yii2-httpclient.
But overall the problem sounds very weird as well as solution. I don't get how database re-connect is related to HTTP request time.
from yii2-httpclient.
Related Issues (20)
- More details on HTTP Status Line Header HOT 2
- How to catch exceptions in bulk request sending?
- Memory leak issue when response headers are empty HOT 1
- CurlTransport sends no error code while throwing Exception
- Client duplicates the response from the server making it invalid HOT 3
- Undefined variable: http_response_header HOT 1
- Uncaught TypeError when `fopen` returns false on PHP8 HOT 5
- StreamTransport does not verify SSL certificates HOT 3
- Instance with header Bearer HOT 1
- response body with string "0" turn out into null
- Debug panel renders error on PHP 8.1 HOT 1
- Shorcut Get methd with params generates a malformed request (Your client has issued a malformed or illegal request) HOT 2
- debug panel throw ErrorException HOT 2
- update github folder link
- update docs folder link
- update src folder link
- update root folder link
- Timeout setting is invalid HOT 3
- Unrecognized format HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-httpclient.