Jedis exception when ADB connection pulled

46 views
Skip to first unread message

Mark Brown

unread,
Jul 17, 2020, 3:01:42 PM7/17/20
to Jedis
Hello,

We have an Android application that stores data on the tablet using Jedis. In order to debug the application, we have an ethernet cable connected between the tablet and the laptop with USB to ethernet dongles on each end.  We then can debug using Android Studio over ADB.

While debugging, if I remove one of the USB dongles, the application will continue to run.  However, I have a Jedis connection that becomes permanently broken.  I'm seeing a stack trace that looks like this when we try to use the connection:

Stack trace:
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: socket failed: ENONET (Machine is not on the network)
at redis.clients.jedis.Connection.connect(Connection.java:207)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
at redis.clients.jedis.BinaryClient.hgetAll(BinaryClient.java:294)
at redis.clients.jedis.Client.hgetAll(Client.java:222)
at redis.clients.jedis.Jedis.hgetAll(Jedis.java:847)
.
.
.
Caused by: java.net.SocketException: socket failed: ENONET (Machine is not on the network)
at java.net.Socket.createImpl(Socket.java:492)
at java.net.Socket.getImpl(Socket.java:552)
at java.net.Socket.setReuseAddress(Socket.java:1493)
at redis.clients.jedis.Connection.connect(Connection.java:174)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93) 
at redis.clients.jedis.Connection.sendCommand(Connection.java:126) 
at redis.clients.jedis.BinaryClient.hgetAll(BinaryClient.java:294) 
at redis.clients.jedis.Client.hgetAll(Client.java:222) 
at redis.clients.jedis.Jedis.hgetAll(Jedis.java:847) 

I attempted to close/disconnect the connection and then reconnect, but that also doesn't resolve the issue.  The only way to restore the connection is to stop and restart the app.

Has anyone else seen this problem and is there a workaround?  We are currently using Jedis 2.9.0 on Android SDK 28.

Thanks,
Mark

Sazzadul

unread,
Sep 5, 2020, 3:01:14 AM9/5/20
to Jedis
The current idea of Jedis is that if one Jedis object gets broken, the user would create a new Jedis object.

JedisPool can handle it for you. But you would require a new dependency, commons-pool2.

Mark Brown

unread,
Feb 9, 2021, 9:45:54 AM2/9/21
to Jedis
We believe we have finally found root cause for this issue.

Our application is using the ConnectivityManager to make the call bindProcessToNetwork().  When the network connection momentarily drops that we were bound to, we failed to bind ourselves to the new connection when it comes back up.  Subsequent connections will be using this non-existent network and leads to the connection failures we were seeing.  So, this has nothing to do with Jedis.  :)

Hope this helps someone in the future.

Reply all
Reply to author
Forward
0 new messages