|
Posted
about 13 years
ago
by
sublambda
October 15, 2012
sublambda commented on issue netty/netty#650
@normanmaurer thanks for the explanation, sorry not to get back to this sooner.
so in fact this change exposed a flaw in my application logic: for each
... [More]
server channel I was binding, I was also carelessly creating a new ServerBootstrap, on the assumption that they were relatively cheap (which they were in earlier versions). With your new pre-allocation strategy, this assumption is no longer valid, since each new ServerBootstrap gives rise to another pool of Selectors. Simple fix to ensure that I only create the ServerBootstrap once.
So all is well, your explanation nudged me to examine my code more critically, glad I didn't assume this was a netty bug.
[Less]
|
|
Posted
about 13 years
ago
by
sublambda
October 15, 2012
sublambda closed issue netty/netty#650
file descriptor proliferation in netty 3.5.8
|
|
Posted
about 13 years
ago
by
aldarund
October 15, 2012
aldarund opened issue netty/netty#653
ChannelListener fires after channelConnected when using OIO
|
|
October 15, 2012
normanmaurer commented on issue netty/netty#647
Ok thats a bug.. can you open an issue for it ?
|
|
Posted
about 13 years
ago
by
aldarund
October 15, 2012
aldarund commented on issue netty/netty#647
Yes, when i changed to OIO channelListener was fires after channelConnected.
|
October 15, 2012
normanmaurer commented on issue netty/netty#647
The ChannelListener should always get fired first. If thats not the case in OIO it's a bug. Can you confirm that this is the case ?
Am 15.10.2012
... [More]
um 14:29 schrieb aldarund <[email protected]>:
> logger.debug('Channel Connected');
> AttachmentObject attachment = (AttachmentObject) ctx.getChannel().getAttachment();
> if (attachment != null) {
> final TimerContext time = IB_REQ_TIMER.time();
> attachment.setTimer(time);
> // Send the HTTP request.
> e.getChannel().write(attachment.getHttpRequest());
> } else {
> logger.error('Cannot get channel attachment');
> e.getChannel().close();
> }
> }
> And in my ConnectedListener there were:
>
> @Override
> public void operationComplete(ChannelFuture channelFuture) throws Exception {
> if (channelFuture.isSuccess()) {
> connectSuccess(channelFuture);
> } else {
> if (connectCount.incrementAndGet() > MAX_CONNECT_RETRIES) {
> logger.error('Failed to connect to host:' + socketAddress.toString() + ' Number:'+connectCount.incrementAndGet());
>
> } else {
> // retry
> bootstrap.connect(socketAddress).addListener(this);
> logger.warn('Connection failed. Trying to reconnect to: ' + socketAddress.toString() + ' Number:' + connectCount.toString());
> }
[Less]
|
|
Posted
about 13 years
ago
by
aldarund
October 15, 2012
aldarund commented on issue netty/netty#647
No it doesnt run twice. The managed to fix this problem with some rewriting of my code. In my handler there was this piece of code:
@Override
... [More]
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
logger.debug('Channel Connected');
AttachmentObject attachment = (AttachmentObject) ctx.getChannel().getAttachment();
if (attachment != null) {
final TimerContext time = IB_REQ_TIMER.time();
attachment.setTimer(time);
// Send the HTTP request.
e.getChannel().write(attachment.getHttpRequest());
} else {
logger.error('Cannot get channel attachment');
e.getChannel().close();
}
}
And in my ConnectedListener there were:
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (channelFuture.isSuccess()) {
connectSuccess(channelFuture);
} else {
if (connectCount.incrementAndGet() > MAX_CONNECT_RETRIES) {
logger.error('Failed to connect to host:' + socketAddress.toString() + ' Number:'+connectCount.incrementAndGet());
} else {
// retry
bootstrap.connect(socketAddress).addListener(this);
logger.warn('Connection failed. Trying to reconnect to: ' + socketAddress.toString() + ' Number:' + connectCount.toString());
}
}
}
private void connectSuccess(ChannelFuture channelFuture) throws Exception {
if (time != null) {
time.stop();
}
logger.debug('Connected..');
logger.debug('Processing req: ' + req.toString());
HttpRequest request = createRequest(req);
//add params
StringBuilder params = new StringBuilder();
for (Param param : req.getParams()) {
params.append(param.getName()).append('=').append(param.getValue()).append('&');
}
if (params.length() > 1) {
params.deleteCharAt(params.length() - 1);
}
ChannelBuffer cb = ChannelBuffers.copiedBuffer(params.toString(), Charset.defaultCharset());
request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, cb.readableBytes());
request.setContent(cb);
// logger.debug(request.toString());
logger.debug('Params: ' + params);
channelFuture.getChannel().setAttachment(new AttachmentObject(req, request));
}
private HttpRequest createRequest(ReqMessage req) throws Exception {
URI uri = new URI(req.getUrl());
//image - GET request
if (req instanceof ReqImageMessage) {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.getPath() + '?' + uri.getQuery());
request.setHeader(HttpHeaders.Names.HOST, uri.getHost());
request.setHeader(HttpHeaders.Names.CONTENT_TYPE, 'application/x-www-form-urlencoded');
return request;
}
// Prepare the HTTP request.
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri.getRawPath());
if (req instanceof RedirectedMessage) {
String redirectPath = uri.getRawPath();
if (uri.getQuery() != null && !uri.getQuery().isEmpty()) {
//get redirect params, server not support get
redirectPath = redirectPath.concat('?').concat(uri.getQuery());
}
request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, redirectPath);
}
request.setHeader(HttpHeaders.Names.HOST, uri.getHost());
request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
request.setHeader(HttpHeaders.Names.CONTENT_TYPE, 'application/x-www-form-urlencoded');
request.setHeader(HttpHeaders.Names.USER_AGENT, 'Mobile Device');
ERIBSession session = SessionHelper.getOrCreateEribSession(sessionStore, req.getMobileSessionId());
for (String jsId : session.getjSessionIds()) {
request.addHeader(HttpHeaders.Names.COOKIE, IbConnectorHandler.JSESSIONID + jsId);
}
return request;
}
And looks like it was causing problem. I ended with moving code from channelConnected event to ConnectedListener and this fixed the problem. Also when i was try to use OIO channelConnected was fired first and then only listener, but when using NIO it was reverse.
[Less]
|
|
Posted
about 13 years
ago
by
fredericBregier
October 15, 2012
fredericBregier commented on issue netty/netty#652
@normanmaurer
I just try using the example within Netty (http.upload) by changing writeMenu such as I've the following:
responseContent
... [More]
.append('<tr><td>Fill with value: <br> <input type=text name=\'foo\' size=10></td></tr>');
responseContent
.append('<tr><td>Fill with value: <br> <input type=text name=\'bar\' size=20>');
responseContent.append('</td></tr>');
No other field is added except Submit and Reset Input.
I tried with all 3 methods: GET, POST and multipart/form-data.
I tried using Chrome:
GET
URI: getform=GET
URI: foo=fooval
URI: bar=barval
URI: Send=Send
POST
Is Chunked: false
IsMultipart: false
BODY Attribute: Attribute: Mixed: getform=POST
BODY Attribute: Attribute: Mixed: foo=fooval
BODY Attribute: Attribute: Mixed: bar=barval
BODY Attribute: Attribute: Mixed: Send=Send
multipart/form-data
Is Chunked: false
IsMultipart: true
BODY Attribute: Attribute: Mixed: getform=POST
BODY Attribute: Attribute: Mixed: foo=fooval
BODY Attribute: Attribute: Mixed: bar=barval
BODY Attribute: Attribute: Mixed: Send=Send
END OF CONTENT AT FINAL END
I tried using FireFox: same result.
I tried using IE: same result.
So I don't see any issue there.
May I missed something ?
[Less]
|
|
Posted
about 13 years
ago
by
fredericBregier
fredericBregier forked netty/netty to fredericBregier/netty
October 15, 2012
|
|
October 15, 2012
jeje commented on issue netty/netty#561
@danbim Any help I could provide on this issue?
|