AuthenticateAsClient() freezes/hangs application

Hello, I am testing a secure SSL Stream using a TCP connection with a local server. However, the server is simply a middle man between two clients and does not do anything (or respond with anything when connected). This server is also not secure, so I would expect the TLS 1.2 authentication to fail and throw an exception as I’ve seen in the past.

Unfortunately, when I call the AuthenticateAsClient() method, the entire program freezes/hangs, pausing all threads everywhere, ultimately causing the watchdog to hit and the application to restart. I suspect it is just waiting for a valid response from the server, but it does not receive anything so it just keeps waiting…

I’ve tried changing both the client socket and SSL stream read/write timeouts with no success. I think this is a larger .NET issue with similar posts online, but I wasn’t able to implement some of their solutions because of the more limited scope of TinyCLR. Does anyone have any suggestions?

Do all systems that need to communicate with each other have the same timezone and synchronized times? Try to synchronize them all with the same sntp server before establishing communication otherwise this could be the problem.

I added the NTP sync and that unfortunately did not help.

I did notice, however, that when I unplug the ethernet cable after it freezes, the cable disconnect interrupt triggers and the program is able to resume normally. The AuthenticateAsClient() method throws its exception as expected.

Does this imply it might be something on the ethernet side of things? Is this a common issue?

Update:
Also tried implementing TLS entropy as shown in this post with no success.

send us simple project and what firmware are you using, please?

1 Like

Thank you

we added to AuthenticateAsClient() freezes/hangs application · Issue #1242 · ghi-electronics/TinyCLR-Libraries (github.com)
and will look into it soon

1 Like

Hi, we are working on this issue.

First, I don’t think you sent us right project. Following the code, the function “_networkController.Enable();” is never called. We did force to calling this it.

Second problem is, EstablishNewEthernetConnection and ResetEthernetSystem call together, this causes a recursive loop and free the system.

After we changed your code, test with our simple server (as you want, our sever has no secure and not send anything after accepted the connect).

SITCore throws exception just fine as expected, and no hang/freeze found yet.

But because we changed your code, so please send again with the one you can reproduce the issue, and send us server project that you can the test connection as well.

Because as project you sent, it is ~ 30% we need, 70% left we have to guess what you did, and try to do same. That will cause different testing result, as you know. Anyway below is our result after changed your code.

Hey Dat,

After putting those changes in I’m no longer seeing the issue. I’m not sure what was causing it, but it’s no longer a problem in my main project either. It’s possible it had something to do with my pc/network at the time. I hope I didn’t waste too much time, but I appreciate the help.

We love to hear it :)). Anyway I am closing the issue.