Description
I think this related to our old friend #118, the firmware update having fixed the issue when plain TCP connections are used, but problems persist when an SSL connection is used. I did some quick testing with SSL when the fix for #118 was released, and I reported no problems, but recently I figured out that I just wasn't sending enough data out to trigger the issue.
Symptoms are similar to #118; write() on WiFiClient hangs for somewhere between seconds and forever depending on how much data is being sent and received at the same time. A sample sketch, atwinc1500_hang_ssl.ino, paired with a simple server program (see instructions in the sketch) usually reproduces the problem in less than 30 seconds.
A surprising thing that seems to hint at the underlying problem is that receive throughput is good when the client is sending very little to the server, but awful as it starts sending more (but still not very many) bytes each second. When BYTES_TO_WRITE is set to a small value, like 1, read throughput is between 49-65 KB/s and the connection doesn't hang.
I see similarly good read throughputs with BYTES_TO_WRITE set to values from 1-20. At 30, things start to get shaky. The speeds fluctuate between 1-50 KB/s and the connection often hangs for good around the 30 second mark. With BYTES_TO_WRITE at 100 it usually hangs withing 20 seconds. At 200 read throughput is awful (never breaking 2 KB/s), most calls to write() take a second or more to complete, and the connection hangs up permanently in under 20 seconds.
One positive aspect of this issue compared to #118 is that the scope of the hang seems to be the SSL connection or Wifi library. If the server closes the TCP connection, write() finishes and control does return to my program pretty quickly.
Here's the sketch's output with BYTES_TO_WRITE at to 200, showing very low throughput and a hang at around 3 seconds:
wifi... connected
ssl... connected
1: read 0 bytes/s, writing 200 bytes... done.
2: read 1388 bytes/s, writing 200 bytes... done.
3: read 1446 bytes/s, writing 200 bytes...
pcap of the conversation is attached, showing the hang and me killing the server at the end and the connection being reset.