[ELS61-AUS] TLS 1.2 connection blocked by Connector.open( ) | Telit Cinterion IoT Developer Community
March 24, 2020 - 8:07am, 2372 views
I developed a Java application for SSL connection and then loaded onto the module.
The following is a part of my code.
SecureConnection secureSocket = (SecureConnection) Connector.open(url);
InputStream secureInputStream = secureSocket.openInputStream();
OutputStream secureOutputStream = secureSocket.openOutputStream();
The call to Connector.open() is blocking when Client can't connect to Server due to a wrong URL or Server breakdown.
The IOException will be thrown about 30 seconds after the call to Connector.open().
Is the default timeout 30 seconds?
Can I set timeout value?
I found another problem when establishing multiple SSL connections.
The connection failure can occur many *****.
Connector.open() would be broke after 30 seconds each time.
As soon as a successful connection has been established, the connection failure occurs after this connection will cause the application block in Connector.open() even after 30 seconds, and then the application also crashes.
Even though I restart application, this problem can't be solved.
I try to let Client to establish connection using a wrong IP, the application blocks in Connector.open(), even if the successful connection has never been estatblished after restarting the applcation.
I can only solve this problem by rebooting the module.
How to break out of Connector.open()?
Hello,
This time you have observed is probably a result of TCP layer delays, retransmissions etc. Problems in attachment to data service (due to for example poor signal quality) could probably also contribute to this time sometimes.
Please see MR, IRT and tcpOT parameters configurable with AT^SCFG command.
As I undestand in your case it is usually 30 seconds. But in some cases it is longer? Have you tried to wait to see how long it can take?
If you need to break this period you'd probably need to try to close this connection from another thread.
Regards,
Bartłomiej
Hello Bartłomiej,
The result of AT^SCFG? is as follows.
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
Modifying the value of MR does not affect the timeout value of Connector.open() at all.
Connector.open() still takes 30 seconds to time out.
I think that MR, IRT and tcpOT parameters only affect the socket connection established by AT command.
I have tried to wait more than ten minutes when the connection failure occurs after one successful connection has been established.
My orignal source code is as follows.
SecureConnection secureSocket = (SecureConnection) Connector.open(url);
secureSocket.setSocketOption(SocketConnection.KEEPALIVE, 1); //comment out this line
When I comments out the code about KEEPALIVE setting, the problem that program is stuck in Connector.open() will be solved.
Best Regards,
Tammy Tsai
Hello,
Thank you for this information. So not changing KEEPALIVE default value solves all the problems that you have described?
As for MR, IRT and tcpOT values there's also com.cinterion.misc.NetExtension class which can be used to adopt these values in Java app. I'm sorry for misleading you.
Regards,
Bartłomiej
Hello Bartłomiej,
When I disable KEEPALIVE, the application will not be stuck in Connector.open().
Connector.open() will throw an IOException after 30 seconds.
Setting KEEPALIVE to zero can solve my problem, but I still don't know why KEEPALIVE setting causes this problem.
As for MR, IRT and tcpOT, do you mean that NetExtension.SetTcpNR(int nr), NetExtension.SetTcpIRT(int irt) and NetExtension.SetTcpOT(int ot) can be used to adjust timeout value of Connector.open()?
Best Regards,
Tammy
Hello,
For now I also can't answer this question - I can only suggest not to set it.
As for NetExtension class it is intended for Java apps and all the changes it can make should affect Java apps.
Regards,
Bartłomiej
Hello,
I will try to modify my Java application at your suggestion.
Thanks for your help.
Best Regards,
Tammy