Bug #86363 JDBC socket timeout set to 15ms regardless of uri settings
Submitted: 17 May 2017 19:34 Modified: 18 May 2017 18:00
Reporter: Joseph Gleason Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.42 OS:Debian
Assigned to: CPU Architecture:Any

[17 May 2017 19:34] Joseph Gleason
Description:
$ javac -version javac 1.8.0_121 
$ java -version openjdk version "1.8.0_121" OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-4-b13) OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

mysql-connector-java-5.1.42-bin.jar
Having trouble connecting to mysql databases that are not on immediate LAN. Suspect strange timeout problem.
In investigation, end up modifying MysqlIO.java from driver adding a line to print socket timeout. See that it is being set to 15 (ms). Sweet.
Adding debug shows that MysqlIO.java line 305 this.mysqlConnection.setSoTimeout(socketTimeout) is getting 15L. Changing that line fixes my problem.
Not sure where the 15 is coming from.
Don't think it matters but here is my connect uri: jdbc:mysql://address=(protocol=tcp)(host=db.fireduck.com)(port=3306)/walletrecover?connectTimeout=18000&socketTimeout=120000

How to repeat:
Use JDBC driver, connect to distant database (more than 15 ms away).

Suggested fix:
Figure out why that is being set to 15 and stop that.  Default should be 0 - no timeout as per docs.  15 seconds would also be reasonable, which I suspect might be the intent.
[18 May 2017 10:45] Chiranjeevi Battula
Hello  Joseph Gleason,

Thank you for the bug report.
I tried to reproduce the issue at my end using MySQL Connector / J 5.1.42 and MySQL 5.7.18 but not seeing any issues in connectTimeout and socketTimeout.
Could you please provide repeatable test case (exact steps, sample test case, database/create table statements, full stack trace  etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[18 May 2017 18:00] Joseph Gleason
And I am an idiot.  The short timeout was coming from a connection pooling library that I just copied from another project.

I only actually looked at that code when I was looking at it to try to make a minimal reproduction.

props.put("socketTimeout", "15");

I will go laugh at myself now.  Thanks for your time.