Hi Ruchira, In APIM and APPM we talk to the BPS server and fetch Human Tasks available. For that when the user is login to the admin-dashboard jaggery app, we do a login call to BPS server using XMLHttpRequest. At this point, if the BPS is not running we are getting this connection refused error in the logs. We need to handle this.
As Tharindu mentioned, XMLHttpRequestHostObject.java uses log.error(e.getMessage(), e); [1]. Therefore we can't get rid of this stack trace in the log by just catching the exception. Is there any method in jaggery that we can use to check whether server is up and running before doing the send call and handle this? Appreciate any help on this. [1] https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java [2]https://wso2.org/jira/browse/APPM-587 [3]https://wso2.org/jira/browse/APIMANAGER-3139 Thanks, Lakmali On 18 March 2015 at 08:57, Tharindu Dharmarathna <[email protected]> wrote: > Hi Ruchira, > > We want to carch the exception according to connection refused exception > from the jaggery side . Due to logging of this exception from Hostobject > We couldn't remove this exception come from the console. > > Is there any way of check a server is up and running from jaggery side . > If there's a way we can avoid exception come from the console. > > Thanks > Tharindu > > On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha <[email protected]> > wrote: > >> What is the issue with going try/catch blocks? >> >> /Ruchira >> >> On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna < >> [email protected]> wrote: >> >>> Hi all, >>> >>> According to public jira [1] how can we handle connection refused >>> exception come from this issue . This come from the send method. >>> >>> code snippest for this issue >>> >>>> >>>> try{ >>>> var xhr = new XMLHttpRequest(); >>>> var site = require("/site/conf/site.json"); >>>> var endpoint = >>>> site.workflows.applicationWorkFlowServerURL+"AuthenticationAdmin"; >>>> xhr.open("POST", endpoint); >>>> var payload = '<soap:Envelope xmlns:soap=" >>>> http://www.w3.org/2003/05/soap-envelope" xmlns:aut=" >>>> http://authentication.services.core.carbon.wso2.org"><soap:Header/><soap:Body><aut:login><aut:username>' >>>> + username + '</aut:username><aut:password>' + password + >>>> '</aut:password><aut:remoteAddress>localhost</aut:remoteAddress></aut:login></soap:Body></soap:Envelope>'; >>>> xhr.send(payload); >>>> var cookie = (xhr.getAllResponseHeaders()); >>>> log.info(xhr.readyState); >>>> //session.put("workflowCookie",cookie.split(";")[0].split(":")[1]); >>>> var sessionCookie = xhr.getResponseHeader("Set-Cookie"); >>>> session.put("workflowCookie",sessionCookie); >>>> }catch (e) { >>>> // log.error(e.message); >>>> } >>> >>> >>> Exception come from the following jaggery hostobject code >>> >>> private static void executeRequest(Context cx, XMLHttpRequestHostObject >>>> xhr) throws ScriptException { >>>> try { >>>> xhr.httpClient.executeMethod(xhr.method); >>>> xhr.statusLine = xhr.method.getStatusLine(); >>>> xhr.responseHeaders = xhr.method.getResponseHeaders(); >>>> updateReadyState(cx, xhr, HEADERS_RECEIVED); >>>> byte[] response = xhr.method.getResponseBody(); >>>> if (response.length > 0) { >>>> xhr.responseText = new String(response); >>>> } >>>> Header contentType = xhr.method.getResponseHeader("Content-Type"); >>>> if (contentType != null) { >>>> xhr.responseType = contentType.getValue(); >>>> } >>>> updateReadyState(cx, xhr, DONE); >>>> } catch (IOException e) { >>>> log.error(e.getMessage(), e); >>>> throw new ScriptException(e); >>>> } finally { >>>> xhr.method.releaseConnection(); >>>> } >>>> } >>> >>> XMLHttpRequestHostObject.java >>> >>> [1] - https://wso2.org/jira/browse/APIMANAGER-3139 >>> >>> Thanks and regards >>> >>> >>> *Tharindu Dharmarathna*Associate Software Engineer >>> WSO2 Inc.; http://wso2.com >>> lean.enterprise.middleware >>> >>> mobile: *+94779109091 <%2B94779109091>* >>> >> >> >> >> -- >> >> *Ruchira Wageesha**Associate Technical Lead* >> *WSO2 Inc. - lean . enterprise . middleware | wso2.com <http://wso2.com>* >> >> *email: [email protected] <[email protected]>, blog: >> ruchirawageesha.blogspot.com <http://ruchirawageesha.blogspot.com>, >> mobile: +94 77 5493444 <%2B94%2077%205493444>* >> > > > > -- > > *Tharindu Dharmarathna*Associate Software Engineer > WSO2 Inc.; http://wso2.com > lean.enterprise.middleware > > mobile: *+94779109091 <%2B94779109091>* > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Lakmali Baminiwatta Senior Software Engineer WSO2, Inc.: http://wso2.com lean.enterprise.middleware mobile: +94 71 2335936 blog : lakmali.com
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
