Does our webservice call close the connection?

Home for older / inactive topics

Does our webservice call close the connection?

Postby s.wit » Thu Jun 19, 2014 2:33 pm

Do we close the connection to the webservice of the backoffice?

On the Tomcat server hosting the (REST) webservices of the backoffice we sessions being created. These sessions are only terminated after the idle time-out has been passed.
Can anyone verify that we are closing the connection to the backoffice webservice after each request, in other words: that we have implemented the Servoy side correctly?

The following two functions handle the webservice calls to the backoffice:
function fillData(url, requestObj) {
var client = plugins.http.createNewHttpClient();
if(client)
{
var request = client.createPutRequest(url);
if(requestObj)
{
var jsonString = JSON.stringify(requestObj);
request.setBodyContent(jsonString, 'application/json');
}
request.addHeader('accept','application/json')
var response = request.executeRequest();
var httpCode = response.getStatusCode();
}
if(httpCode == plugins.http.HTTP_STATUS.SC_OK)
{
return true
}
return false
}

function getPostData(url)
{
var client = plugins.http.createNewHttpClient();
if(client)
{
var request = client.createGetRequest(url);
request.addHeader('accept','application/json')
var response = request.executeRequest();
var httpCode = response.getStatusCode();
}
if(httpCode == plugins.http.HTTP_STATUS.SC_OK)
{
var content = response.getResponseBody();
var data = plugins.serialize.fromJSON(content)
}
return data
}

With kind regards,
Serge de Wit
s.wit
 
Posts: 4
Joined: Thu Jun 19, 2014 2:19 pm

Re: Does our webservice call close the connection?

Postby Andrei Costescu » Fri Jul 04, 2014 2:24 pm

Http plugin doesn't keep any connections open.
It should be the same as you if you would start a browser, access a few URLs from the back-office and then close the browser app.

You could - at the end do a special request to the back-office app. that will be interpreted as "discard session" - and the back-office discards the session when it gets that request (similar to a "log-out").
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Does our webservice call close the connection?

Postby s.wit » Fri Oct 17, 2014 11:22 am

Adding the solution for others who use these forums:

Servoy has added the "response.close();" statement in order to neatly close the connection between the servoy application server and external webservice.
s.wit
 
Posts: 4
Joined: Thu Jun 19, 2014 2:19 pm


Return to Archive

Who is online

Users browsing this forum: No registered users and 1 guest