php - ElasticSearch query hangs in laravel job queue -


i using laravel-elasticsearch provider es queries. using within job processed laravel queue(using beanstalkd). problem having in long running jobs, no longer able insert data elasticsearch. job hangs (no exceptions thrown) have narrowed down code making es call. possible connection become stale how , not reconnect? other thought has using facade , being singleton.

here doing, not exact code. code works fine when not run in long running job.i wanted provide context.it inserts fine, there no issues code functioning until run after long running process.

update:

i have narrowed issue down elasticsearch-php library persisting connection. have es behind load balancer times out tcp connections after 5 min. issue there no keep alive in es php library. after 5 min connection closed not close connection on end. there way set keep alive elasticsearch-php? or call reset connection?

//run functions.... $params = array(); $params['body']  = array('somefield' => 'some data'); $params['index'] = 'my_index'; $params['type']  = 'my_type'; $params['id']    = 'my_id'; $ret = es::update($params);//this working fine  //long running function here $newparams = array(); $newparams['body']  = array('somefield' => 'some data'); $newparams['index'] = 'my_index'; $newparams['type']  = 'my_type'; $newparams['id']    = 'my_id'; $return = es::update($newparams);//this hang 

gather around, , let's talk long lasting queue processes.

laravel queues work, workers. rentless elves fetch jobs our queue service , processes them in timely fashion.

however, after long periods of incessant work, our elves start tired , create errors randomly. types of errors include failure to send mail using swiftmailer, process database transactions or connect ssl ports.

what our elves need, energy drink, in form of queue:restart, every 20 mins.

steps implement:

1) if on linux, type in console sudo crontab -e

2) using vim, enter following lines 0,20,40 * * * * cd /path/to/my/laravel/installation && php artisan queue:restart --env=yourenvironment 1>> /dev/null 2>&1

replace /path/to/my/laravel/installation laravel's path.

and yourenvironment laravel's environment name.

source: have elasticsearch installation uptime of 1 month, , laravel polling , updating data in real-time using shift31's package.

documentation: http://laravel.com/docs/5.0/queues#daemon-queue-worker


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -