Apache Curator connection state listener not always called with RECONNECTED state change - apache-curator

I am using Apache Curator v4.3.0 (ZK v3.5.8), and I noticed that in some disconnect/reconnect scenarios, I stop getting a RECONNECTED event to the registered listener/s.
CuratorFramework client = ...;
// retry policy is RetryUntilElapsed with Integer.MAX_VALUE
// sessionTimeout is 15 sec
// connectionTimeout is 5 sec
client.getConnectionStateListenable().addListener(new ConnectionStateListener()...
Although I do see that the ConnectionStateManager prints the state change:
[org.apache.zookeeper.ClientCnxn] - Client session timed out, have not heard from server in 15013ms for sessionid 0x10000037e340012, closing socket connection and attempting reconnect
[org.apache.zookeeper.ClientCnxn] - Opening socket connection to server
...
[org.apache.curator.ConnectionState] - Session expired event received
[org.apache.zookeeper.ClientCnxn] - Session establishment complete on server
[org.apache.curator.framework.state.ConnectionStateManager] - State change: RECONNECTED
Usually right after I see my listener called on stateChanged, but not always.
The CuratorFramework client is shared between multiple components registering different listeners. I didn't see any restriction to have only one client per listener. But, when I don't share it, the problem doesn't occur anymore.
Any suggestions on how to proceed debugging this problem?
Thank you,
Meron

This appears to be the bug that was fixed in Curator 5.0.0 - https://issues.apache.org/jira/browse/CURATOR-525 - if you can please test with 5.0.0 and see if it fixes the issue.

Related

SiebelDataBean - Logon Request XXX on connection XXXXXXX was abandoned

We are using SiebelDataBean to connect to Siebel EAIObjMgrAPI component using below process provided.
https://docs.oracle.com/cd/E14004_01/books/OIRef/Customizing_Siebel_Object_Interfaces12.html
The application works fine for a while and then start throwing below error, kindly let me know if anyone else has encountered this issue.
[CMGR WARNING] Received notification: The task 257950792 has either been shutdown or timed-out connection:f600448
Logon Request 106 on connection 2100445 was abandoned after 30001 ms because it timed out.(SBL-JCA-00317)
Check the SISNAPI idle timeout setting on the EAI component parameters. If there is no activity for that much seconds, the system logs out the session to preserve memory.

Websphere application server LDAP connection pool

We are using websphere application server 8.5.0.0. we have a requirement where we have to query a LDAP server to get the customer details. I tried to configure the connection pool as described here and here.
I passed the below JVM arguments
-Dcom.sun.jndi.ldap.connect.pool.maxsize=5
-Dcom.sun.jndi.ldap.connect.pool.timeout=60000
-Dcom.sun.jndi.ldap.connect.pool.debug=all
Below is a sample code snippet
Hashtable<String,String> env = new Hashtable<String,String>();
...
...
env.put("com.sun.jndi.ldap.connect.pool", "true");
env.put("com.sun.jndi.ldap.connect.timeout", "5000");
InitialDirContext c = new InitialDirContext(env);
...
...
c.close();
I have two issues here
When I am calling the service for the 6th time, I am getting javax.naming.ConnectionException: Timeout exceeded while waiting for a connection: 5000ms. I checked the connection pool debug logs and I noticed the connections are not returning back to the pool immediately despite closing the context safely in a finally block. The connections are released after some time and expired after sometime after the release. There after if I call the service again, it connects to the LDAP server but new connections are being created.
I tried to execute the code and I am able to see the connection pool debug logs. But the logs are being logged in System.Err log. Is this an issue? Can I ignore it?
But when I run the code as a standalone application(multithreaded with loop of 50 times), the connections are returned/released immediately.
Can anyone please let me know what am I doing wrong?

MCOErrorAuthentication performing background fetch

I'm fetching messages on background from IMAP server using performFetchWithCompletionHandler.
The first thing I do on method implementation is check for network reachability, discarding operation if its no available.
Then I start refresh process executing fetchMessagesOperationWithFolder on a IMAP session.
As result of this operation I usually receive no error, but sometimes I receive an MCOErrorParse (Unable to parse response from server), MCOErrorConnection (A stable connection to the server could not be established) or MCOErrorAuthentication (Unable to authenticate with the current session's credentials).
Can all this errors be produced due to connection failure?
I want to handle the MCOErrorAuthentication to notify user on the credentials error, but in this scenario the credentials are ok, so when I perform any operation when on foreground again with network reachability it will succeed.
Should I do an extra network connection check before proceed on those errors? Should I create a new IMAP session on every operation?
Thanks!
Edit
I'm adding ConnectionLog, it take me long to reproduce the error. Its very clear why I receive a MCOErrorAuthentation: I'm not loading password well.
2014-12-18 21:00:41.212 * OK Gimap ready for requests from 85.58.177.133 et58mb78762219web
2014-12-18 21:00:41.222 1 CAPABILITY
2014-12-18 21:00:41.302 * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
1 OK Thats all she wrote! et58mb78762219web
2014-12-18 21:00:41.304 2 LOGIN “polferresamon#gmail.com" ""
2014-12-18 21:00:41.378 2 NO Empty username or password. et58mb78762219web
2014-12-18 21:00:41.380 Error fetching messages: Unable to authenticate with the current session's credentials.
So, to really solve MCOErrorAuthentication I have to check IMAP session init, and the process where I'm loading email and password when returning from background.
I guess parse and connection errors are due to connection issues.
Thanks for your help.

heartBeatIntervalInSecs does not have effect if the application starts with the server stopped

WL 6.1
I have an application with:
ConnectOnStartup: true
heartBeatIntervalInSecs: 30
If the server is started and I start the application I can see in the application log a trace each 30sec for the heartbeat
But if the server is stopped and I start the application there is no trace for the heartbeat.
I handle the connection error with the onConnectionFailure and I let the application to start.
Is this ok? How could I enable the heartbeat manually?
I have tested this on Android.
Thank you.
There is API for this: WL.Client.setHeartBeatInterval(interval)
Accepts:
-1 to disable
Any other number (in seconds)
In your implementation simply either disable or enable (by setting an interval) whenever required.

Frequent disconnects with XHR-Polling, Socket.io and Titanium

I'm using Socket.io on the Titanium framework via https://github.com/nowelium/socket.io-titanium. So far, that "port" only supports the XHR-polling transport. In the past, I've had success with Socket.io using the Websocket transport.
The problem I'm having now is that my socket connection seems to "drop" every 10 seconds for a few seconds at a time. This means chat messages are dropped, etc. Is this expected behavior with XHR-polling - do I need a implement a queue system - or is there some way I can look to fix this issue?
debug - setting poll timeoutdebug - discarding transport
debug - cleared close timeout for client 407473253144647189
debug - clearing poll timeout
info - transport end
debug - set close timeout for client 407473253144647189
debug - cleared close timeout for client 407473253144647189
debug - discarding transport
debug - client authorized
info - handshake authorized 4149191422068834219
debug - setting request GET /socket.io/1/xhr-polling/4149191422068834219?t=Thu%20Jan%2012%202012%2022%3A37%3A47%20GMT-0800%20%28PST%29
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - xhr-polling writing 1::
debug - set close timeout for client 4149191422068834219
Connection
debug - setting request GET /socket.io/1/xhr-polling/4149191422068834219?t=Thu%20Jan%2012%202012%2022%3A37%3A47%20GMT-0800%20%28PST%29
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 4149191422068834219
Last login: Fri Jan 13 00:04:14 on ttys003
Why don't you load socket.io.js in a web view and pump events via Ti.App.fireEvent / addEventListener? That gives you WebSockets, which doesn't have the limitations of polling.
<html>
<head>
<script src="http://63.10.10.123:1337/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://63.10.10.123:1337');
socket.on('onSomething', function (data) {
Ti.App.fireEvent('onSomething', data);
});
Ti.App.addEventListener('emitSomething', function (data) {
socket.emit('emitSomething', data);
});
</script>
</head>
<body>
</body>
</html>
EDIT: I want to note that I did this in a project, and it was crashing my app very consistently on iOS. I looked around, and other devs were hitting this too even without using Titanium. I wouldn't recommend taking this approach, or at the very least, testing it very thoroughly (especially backgrounding and resuming the app). Instead, I use Appcelerator's TCP sockets with my own light protocol to stream data from client to server and server to client.