javascript - Is there any way to keep LG WebOS service alive? -


i’m trying create js service on webos 3.0 followed official documentation.

i can send data between js service , application, js service not respond request if it’s idled 20 seconds. i’ve tried increase timeout per this. unfortunately, not seemed working.

here’s code

application side

const request = webos.service.request('luna://com.myapp.service', {         method : 'fetch',         parameters : { url, method, headers, body },         onfailure : (err) => {           reject(err)         },         onsuccess : (s) => {           console.log('request success', s)         },         oncomplete : (resp) => {           const issuccess = resp.data.status >= 200 && resp.data.status < 400           var payload = {             json : () => promise.resolve(json.parse(resp.data.body)),             ok : issuccess,             headers : resp.data.headers,             status : resp.data.status,             error : issuccess               ? null               : resp.data.body           }           resolve(payload)         }       })     }) 

service side

var service = require('webos-service') var service = new service('com.myapp.service')  service.register('fetch', function(message) { var payload = message.payload   if(!payload) {     message.respond({       returnvalue : true,       error : 'message not have `payload`'     })     return   }   var url = payload.url,       headers = payload.headers,       method = payload.method,       body = payload.body   var request = http.request({     method : method,     hostname : url.parse(url).hostname,     path : url.parse(url).path,     headers : headers,   }, function(res) {     var data = ''     res.on('data', function(chunk) { data+=chunk })     res.on('end', function() {       message.respond({         returnvalue : true,         data : {           status : res.statuscode,           statustext : res.statusmessage,           headers : res.headers,           body : data,         }       })     })   })   request.on('error', function(err) {     console.log(err)     message.respond({       returnvalue : true,       error : err     })   })   request.end() }) 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -