Reputation: 615
My webservice code
final StreamingOutput stream = new StreamingOutput() {
@Override
public void write(final OutputStream out) {
dao.getData(
query,
new SdmxObserver(writerFactory.getDataWriter(sdmxFormat, out, properties), request
.getRemoteAddr(), request.getHeader("User-Agent"), query.toString(), sdmxFormat
.toString(), query.getlist()));
}
};
res = Response.ok(stream, MediaType.valueOf("application/vnd.sdmx.genericdata+xml;version=2.1"))
.cacheControl(cc).lastModified(lastModified).header("Vary", "Accept,Accept-Encoding").build();
return res;
The database call to retrive the data is taking long, so when we use the proxy it has time out of 2 minutes and hence as the data is not coming from data base withn 2 minutes it is showing connection time out. Though we have use StreamingOutput then why the streaming is not happening to keep the connection alive? Also if we byepass the proxy then we can get the data sucessfully from the webservice.
But we can't change the proxy setting and also we need to use the application with or without using the proxy.
Upvotes: 0
Views: 618
Reputation: 2273
Chances are your proxy server simply kills the connection after its configured timeout, whether or not you're transferring data. If you were wondering, Connection: keep-alive
header only indicates that the same connection can be reused for multiple request/responses (RFC7230), it is not supposed to control timeout for a single connection.
Try talking to your proxy administrator about:
Keep-alive: timeout=10000
, but could be also something completely different, or may not be possible at all)If that doesn't work out you may need to rethink your design and take a different approach, for example Spring Data + pageable resources or, if you feel brave, asynchronous processing with Spring Integration + Splitter pattern.
Upvotes: 1