I am Getting an error
"504 Gateway Timeout - The gateway did not receive a timely response
from the upstream server or application"
after 20 minute of run my Script from Cron
I am using codeigniter version 3 got one solution php-ignoring-my-max-execution-time
but Below Code not found in system/core/CodeIgniter.php codeigniter version 3
if (function_exists("set_time_limit") == TRUE AND #ini_get("safe_mode") == 0){
#set_time_limit(300);}
How to increase max-execution-time in codeigniter 3?
You can try this:
ini_set('max_execution_time', 0);
Related
the gmail smtp-relay works fine using the sync driver, but if we queue the email we this error. cleared config, cache, & restarted queue workers. tested in prod and dev, same results
[2021-01-24 20:04:22] production.ERROR: Expected response code 250 but got an empty response {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /home/****/****/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448)
were wondering is this because of serialization and something is not making it through that process???
using latest stable release of laravel >8.0. gmail smtp is authenticating just fine, per why the sync driver sends emails easily. maybe there needs to be a timeout on the queue jobs so they dont barrage gmail so quickly? also our code works fine using sendgrid for example as the smtp relay. thanks.
See https://laracasts.com/discuss/channels/laravel/laravel-swift-mailer-exception-expected-response-code-250-but-got-an-empty-response-using-gmail-smtp-relay-database-queue-driver
Update your AppServiceProvider.php
add this inside boot();
// Fix for SwiftMailer Service;
$_SERVER["SERVER_NAME"] = "your.domain.name";
For users of smtp-relay.gmail.com, if you use localhost/127.0.0.1 as domain during developments, you probably need to change the domain name to use in EHLO command to begin the transaction. I solved this by adding &local_domain=dev.mydomain.tld at the and of my DSN.
smtp://smtp-relay.gmail.com:587?encryption=tls&local_domain=dev.mydomain.tld&...
For SwiftMailer Symfony bundle (since 2.4.0), you can set the local_domain config parameter:
// config/packages/dev/swiftmailer.yaml
swiftmailer:
...
local_domain: dev.mydomain.tld
Explanation for the 2 previous Answers
if $_SERVER["SERVER_NAME"] is the solution:
When you are using cron
The reason is that $_SERVER["SERVER_NAME"] is null when cron is executed. $_SERVER["SERVER_NAME"] is usually only defined for http access.
Example implementation (laravel):
if (!isset($_SERVER['SERVER_NAME'])) {
$url = config('env.APP_URL');
$domain = mb_ereg_replace("http(s)? ://", "", $url);
$domainParts = explode('/', $domain);
ini_set('server_name', count($domainParts) > 0 ? $domainParts[0] : $domain)
}
References :
Cron Job $_SERVER issue
https://github.com/swiftmailer/swiftmailer/issues/992
if 'local_domain' is the solution
When you have a mailhost setting of MAIL_HOST=smtp-relay.gmail.com in your laravel project
The reason is that if local_domain' is not set, the protocol for mail communication with Gmail will be EHLO [127.0.0.1]` and the communication will be disconnected.
By the way, I used gmail->gmail alias and did not need relay in the first place, so I solved the problem by setting MAIL_HOST=smtp.gmail.com.
References:
https://blog.trippyboy.com/2021/laravel/laravel-expected-response-code-250-but-got-an-empty-response/
I had to deal with both of them because of cron messaging and MAIL_HOST=smtp-relay.gmail.com in my environment.
I hope this information will help you.
Would like to check, I am fairly new to Bitbucket's new introduced webhook where previously i was using services where Bitbucket will execute a link to my site thus triggering a deployment script.
So since the old service is going to be depreciated soon, we all migrated to webhook instead. With the same implementation, I keep getting an error 500 upon commit/push/merge and there is no way for us to see the details for the error given. At first I thought it was my server giving problem but when i call the link manually via browsers and everything was fine. The deployment script can be executed successfully so then why bitbucket's webhook keeps telling me error 500?
Subsequently I find the guide given by Bitbucket was not helpful. There is no specified call method to the url stated so is the webhook initiates a GET or POST request? previously using services initiates a POST request. Then, are there any necessary payloads i need to include into the webhook URL? None is stated. Then, if there is an error at least let me see the error so I can fix it instead of telling me error 500.
I hope someone here can help me with this issue. Below are some specification of the site.
Server : Ubuntu LEMP 14.04 x64 Laravel framework 5.0
Webhook Url: bot.example.com/bitbucket/deploy/{Site API}
Method : GET
And when the abode link is call, it reaches a controller that does
public function attemptDeploy($site_api)
{
$script = 'nohup setsid php ~/scripts/deploy.php ' . $site_api. ' > /dev/null 2>&1 &';
exec($script);
return response('Deploy running.', 200);
}
Note that when i call this link manually either form browser or console everything works perfectly except from bitbucket's webhook. How can i solve this issue?
I was in the same situation. Bitbucket trims the body of the response and I couldn't see the error given by my server.
I've looked into the logs storage/logs/laravel.log and saw TokenMismatchException. Webhooks being API calls they don't store cookies or sessions so CSRF from Laravel breaks.
You need to add an exception from CSRF for the bitbucket deploy route. You can add this exception in app/Http/Middleware/VerifyCsrfToken.php. For example if your link is www.your_site.com/bit_deploy you will have:
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* #var array
*/
protected $except = [
'bit_deploy'
];
}
Hope that this helps you ... as I've lost 3 hours on this.
PS: at the time of writing this answer, bitbucket webhooks performs POST calls (not GET)
i am using , https://github.com/blueimp/jQuery-File-Upload plugin for image upload using ajax call in laravel 5. i also refered article http://peterjolson.com/using-laravel-and-jquery-file-upload/. but i am getting the following error error
GET http://localhost:8000/...../server/php/ 500 (Internal
Server Error)
when i use https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin i get the same error. Can anyone help with this or please suggest any working image uploader with ajax call for laravel 5
There is a main.js file, you need to adjust the url there according to the path you store it:
url: '../../uploadimage/server/php/'
I have a PhoneGap project and lately I've been been hitting a lot of random "status 0" results. I can literally try the same end-point 10 times in a row, passing the same post parameters, and the status will flip between a 200 and a 0. In both cases, the results return almost instantly - it is not a timeout issue.
I'm using PhoneGap in iOS, if the platform is a factor. Does anyone have any ideas on where to start looking?
FYI - I implemented the tip at Ajax https call in ios using PhoneGap not working?. At first I thought it helped, but perhaps it was just a run of good luck.
It is perfectly normal to get a status of 0 when requesting a URL over AJAX. Since some browsers will return a 0 on a CORS request but since you are doing your request from the file:// protocol CORS does not apply. When I do a AJAX request I take 200 and 0 as a success.
Is there a limit to the number of simultaneous Ajax requests than can be launched toward an Apache server? For example, consider the following function to update div elements on a page (prototype JS):
function trigger_content_update(cell) {
//asynchronous : false is required for this to work properly
$$('.update').each(function(update_item){
new Ajax.Request('/neighbouring?.state=update_template&dummy='+(new Date()).getTime(),{
asynchronous: false,
parameters: {divid: update_item.id, source: cell},
onComplete: function(response) {
var elm = response.getHeader('Element');
if ($(elm) !== null) { $(elm).update(response.responseText) }
}
});
});
}
On my HTML page, there are 8 div elements that are marked with the "update" CSS selector, thus launching 8 ajax requests. The code works fine with the asynchronous property set to false, but as soon as i set asynchronous:true i can observe (in Firebug) most Ajax requests returning a 500 status (internal server error).
Once this occurs, it is required to restart apache to recover.
I'd check the server side code that's handling the requests.
As far as Apache is concerned, your Ajax request is just a POST - the same as if you'd submitted a form. 8 simultaneous requests should easily be handled by Apache, so it suggests that the server side code that Apache is running is locking up - perhaps it's trying to write to a data file and finding it locked?
I just wrote a test case where I sent out 10,000 simultanuous Ajax calls to a service. Works fine on Apache Tomcat. All service came back with a proper answer.
It sounds like your service is having some internal synchronization issues.