-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasync freezes using specialized clients on connecting to non-available server process #66
Comments
Hi, added @Test
public void testTimeoutAtmosphereClient() throws IOException, InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
AtmosphereClient client = ClientFactory.getDefault().newClient(AtmosphereClient.class);
RequestBuilder request = client.newRequestBuilder()
.method(Request.METHOD.GET)
.uri(targetUrl)
.trackMessageLength(true)
.transport(transport());
Socket socket = client.create();
socket.on(new Function<ConnectException>() {
@Override
public void on(ConnectException t) {
latch.countDown();
}
}).on(Event.CLOSE.name(), new Function<String>() {
@Override
public void on(String t) {
logger.info("Connection closed");
}
}).open(request.build());
assertTrue(latch.await(10, TimeUnit.SECONDS));
} But for me I do get the ConnectionException pretty fast. So it seems your use case is different, e.g no ConnectException is thrown, right? |
Hi here is the thing
The In the debugger I see that I end up in the I just ran your Unit Test and it blocks forever on the I checked again and I am using the latest wasync wasync-1.0.0-20130828.144509-85. Are there dependencies I need to check ? but |
Ah you are using an old version. Pull again and let me know. |
So I pulled again, and with your fix the behaviour is consistent between clients. BUT (contrary to what I wrote above), Wouldn't it make more sense to : } else {
f.get(options.waitBeforeUnlocking(), TimeUnit.MILLISECONDS);
}
} catch (Throwable t) {
throw new IOException("Connection could not be established", t);
} finally {
f.done();
} In addition the
|
Salut, ya that make sense...but I really wanted to force the application to define Function to handle that case instead of throwing exception on open(). What is the issue of using Functin? Thanks! |
Hi Jeanfrancois there is nothing wrong with the asynchronous callback. To me (I would also argue that oftentimes the asynchronous IOException handling on a connection that was established is different to handling an IOException indicating that an initial connection can't be established at all.) I checked some other Netty stack implementations of mine and what I usually do is ChannelFuture future = _channel.connect(_remoteAddress);
future.awaitUninterruptibly();
if (!future.isSuccess()) {
throw new SoupBinTCPConnectException("Could not establish a connection to address " + _remoteAddress + " !", future.getCause());
} So as an alternative to throwing in
Let me know what you think. ttyl. |
Hi Jeanfrancois with your fix to #66 I do run into serious problems now. The
It just leads to a Can't you change it to this instead ? if (request.queryString().containsKey("X-atmo-protocol")) {
f.get(options.waitBeforeUnlocking(), TimeUnit.MILLISECONDS);
} else {
f.get(options.waitBeforeUnlocking(), TimeUnit.MILLISECONDS);
} Cheers, Christian. |
Hum...can you tell me how to reproduce this? It's strange all the tests are working fine and the sample....I will take a look as soon as I can. Sorry for all the issues. BTW the code above do the same in both case :-) |
Hi Jeanfrancois I think a lot of your tests work because of the waits you put following the What I perform is an
So the fix should be changed as done in your latest checkin, still doing a blocking So far so good, but I still have a problem with this everything being subject of race conditions. Let's say that my call to
This leaves me, the caller of If lucky, there is an IOException and the I am of the strong opinion that we should have clear
With semantics like these the caller is not left with the heuristical / pretty impossible task of finding out if a socket is ready or not after calling Lemme know what you think, cheers, Christian. |
OK good point. The issues are:
|
OK, fixed. Try 1.1.0-SNAPSHOT and let me know. |
My tests are all working now, perfect ! Thx for being so responsive and open to my suggestions, I think the socket API did improve a lot with these changes (but I might be a bit biased, after all :) ) ! Cheers, Christian. |
@thabach You are always welcomed! I've also fixed an inconsistency with issue 68. Can you try the latest 1.1.0-SNAPSHOT and let me know if all works for you. I will go ahead and release 1.1.0 once I'm sure everything works on your side :-) |
Hi Jeanfrancois there seems to be a new problem now, in this snippet, different to RC5, the connection.connect('JohnD', 'PWD')
println("after connect, connection is connected " + connection.isConnected())
Future f = connection.send(new UnsequencedDataPacketBuilder().message([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as byte[]).build())
f.get(); The code does Let me know, I can work out a unit test later if you wish, Christian. additional info: I am using a SerializedClient. |
@thabach Just to make sure. Do you get that problem with 1.0.0? |
@thabach Ok I'm able to reproduce with the SerializedClient. Fix coming! |
I just tried now and with 1.0.0 it does not freeze on the |
Great, looking forward to it, ready to test :) |
@jfarcand All works fine on my side now, good to go releasing 1.1.0 into wild :) |
Hi Jeanfrancois
When trying to connect to a server (based on Nettosphere) which is not up, the wasync client freezes when using the specialized clients (AtmosphereClient and SerializedClient) instead of throwing an exception. This is rooted in an unconditional
future.get()
inDefaultSocket::connect()
:I am using the latest wasync Snapshot wasync-1.0.0-20130828.144509-85
I am not sure if putting the timeout on the blocking
get()
is the cure, so I did not submit a pull request this time around, regards Christian.The text was updated successfully, but these errors were encountered: