<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — Getting WANT_READ	-323 error]]></title>
		<link>https://www.wolfssl.com/forums/topic2198-getting-wantread-323-error.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic2198.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Getting WANT_READ	-323 error.]]></description>
		<lastBuildDate>Mon, 21 Oct 2024 17:04:01 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Getting WANT_READ	-323 error]]></title>
			<link>https://www.wolfssl.com/forums/post7962.html#p7962</link>
			<description><![CDATA[<p>Hi MO380,</p><p>Please reach out to us at support [AT] wolfssl [DOT] com, you should be able to attach files there.&nbsp; Please attach your user_settings.h/configure line in your ticket.</p><p>Thanks,<br />Kareem</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Mon, 21 Oct 2024 17:04:01 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post7962.html#p7962</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting WANT_READ	-323 error]]></title>
			<link>https://www.wolfssl.com/forums/post7957.html#p7957</link>
			<description><![CDATA[<p>Hi Kareem,</p><p>i&#039;m already connected this is past me and i have also published a greeting to the broker. But after that my paho mqtt library needs to invoke repeatedly a function which handles receiving and also the keepalive, but here it fails. I&#039;m using also my own socket not the one from LWIP. And those are implemented together with timeouts, not using a select on that. So it will stay in amount of time and come back. Well here i would expect 0 as a return, this would be considered a timeout, but unfortunately it comes back with -1. Checking the error returns 0. This should be fine i think so. But question is now how to exit the library correctly. I tried change the return value to WOLFSSL_CBIO_ERR_TIMEOUT, but gave me some other failure -308. </p><p>BTW, not able to upload any file.</p><p>Thanks,<br />MO</p>]]></description>
			<author><![CDATA[null@example.com (MO380)]]></author>
			<pubDate>Sat, 19 Oct 2024 10:32:05 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post7957.html#p7957</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting WANT_READ	-323 error]]></title>
			<link>https://www.wolfssl.com/forums/post7955.html#p7955</link>
			<description><![CDATA[<p>Hi MO380,</p><p>-323 WANT_READ is an expected error during a connection, this just means you should call the connect/read function again until the error goes away.&nbsp; The error is indicating wolfSSL needs to read additional data which hasn&#039;t come in yet.</p><p>Check out our LWIP example here: <a href="https://github.com/wolfSSL/wolfssl-examples/tree/master/lwip">https://github.com/wolfSSL/wolfssl-exam … aster/lwip</a></p><p>Thanks,<br />Kareem</p>]]></description>
			<author><![CDATA[null@example.com (kareem_wolfssl)]]></author>
			<pubDate>Fri, 18 Oct 2024 22:35:46 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post7955.html#p7955</guid>
		</item>
		<item>
			<title><![CDATA[Getting WANT_READ	-323 error]]></title>
			<link>https://www.wolfssl.com/forums/post7954.html#p7954</link>
			<description><![CDATA[<p>Hi, need help can&#039;t figure out why this happens. I like to use my sockets together with SO_RCVTIMEO. And library should handle this, but don&#039;t know if it does. Have added some code which i think causes this to happen. </p><p>int pahoclient_start( const char *ip, int port )<br />{<br />&nbsp; &nbsp; /* Define a structure to hold the WolfSSL context. */<br />&nbsp; &nbsp; WOLFSSL_CTX* ctx;<br />&nbsp; &nbsp; WOLFSSL* ssl = NULL;<br />&nbsp; &nbsp; int fd;</p><p>&nbsp; &nbsp; /* Low level socket apis&nbsp; */<br />&nbsp; &nbsp; NetInit(&amp;net);<br />&nbsp; &nbsp; if(NetConnect(&amp;fd, ip , port, 10000) &lt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return FAILURE;</p><p>&nbsp; &nbsp; net.fd = fd;</p><p>&nbsp; &nbsp; /* enable debugging */<br />#if defined(DEBUG_WOLFSSL)<br />&nbsp; &nbsp; wolfSSL_Debugging_ON();<br />#endif</p><p>&nbsp; &nbsp; /* Setup the WolfSSL library */<br />&nbsp; &nbsp; wolfSSL_Init();</p><p>&nbsp; &nbsp; /* Create and initialize WOLFSSL_CTX */<br />&nbsp; &nbsp; if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {<br />&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stderr, &quot;ERROR: failed to create WOLFSSL_CTX\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; /* Load client certificates into WOLFSSL_CTX */<br />&nbsp; &nbsp; if (wolfSSL_CTX_load_verify_buffer(ctx, client_cert_home,client_cert_home_length, SSL_FILETYPE_PEM) != SSL_SUCCESS) {<br />&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stderr, &quot;ERROR: failed to load %s, please check the file.\n&quot;, client_cert);<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; /* define client callbacks */<br />&nbsp; &nbsp; wolfSSL_CTX_SetIOSend(ctx, TlsSocketSend);<br />&nbsp; &nbsp; wolfSSL_CTX_SetIORecv(ctx, TlsSocketReceive);</p><p>&nbsp; &nbsp; /* Create a WOLFSSL object */<br />&nbsp; &nbsp; if ((ssl = wolfSSL_new(ctx)) == NULL) {<br />&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stderr, &quot;ERROR: failed to create WOLFSSL object\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; /* Attach wolfSSL to the socket */<br />&nbsp; &nbsp; wolfSSL_set_fd(ssl, fd);</p><p>&nbsp; &nbsp; wolfSSL_SetIOReadCtx(ssl, (void *)&amp;net);<br />&nbsp; &nbsp; wolfSSL_SetIOWriteCtx(ssl, (void *)&amp;net);</p><p>&nbsp; &nbsp; /* Connect to wolfSSL on the server side */<br />&nbsp; &nbsp; if (wolfSSL_connect(ssl) != SSL_SUCCESS) {<br />&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stderr, &quot;ERROR: failed to connect to wolfSSL\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; /* mqtt lower level apis */<br />&nbsp; &nbsp; mqtt.mqttread = mqtt_read;<br />&nbsp; &nbsp; mqtt.mqttwrite = mqtt_write;<br />&nbsp; &nbsp; mqtt.disconnect = mqtt_disconnect;</p><p>&nbsp; &nbsp; wolfssl = ssl;</p><p>&nbsp; &nbsp; MQTTClientInit(&amp;client, &amp;mqtt, 10000, sendbuf, sizeof(sendbuf), readbuf, sizeof(readbuf));<br />&nbsp; &nbsp; MQTTPacket_connectData&nbsp; &nbsp; options = MQTTPacket_connectData_initializer;</p><br /><p>&nbsp; &nbsp; options.cleansession = 1;<br />&nbsp; &nbsp; options.clientID.cstring = &quot;ClientID&quot;;<br />&nbsp; &nbsp; options.keepAliveInterval&nbsp; &nbsp; = 6000;<br />&nbsp; &nbsp; options.willFlag = 0;<br />&nbsp; &nbsp; options.MQTTVersion = 3;<br />&nbsp; &nbsp; options.username.cstring = &quot;abcdef&quot;;<br />&nbsp; &nbsp; options.password.cstring = &quot;12345678&quot;;</p><p>&nbsp; &nbsp; if(MQTTConnect(&amp;client, &amp;options) &lt;0 )<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;</p><p>&nbsp; &nbsp; if(MQTTSubscribe(&amp;client, &quot;huhu&quot; , QOS1, MqttMessageArrived) &lt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; goto exit;</p><br /><p>&nbsp; &nbsp; return MQTTSUCCESS;</p><p>exit:<br />&nbsp; &nbsp; wolfSSL_free( ssl );<br />&nbsp; &nbsp; wolfSSL_CTX_free( ctx );<br />&nbsp; &nbsp; wolfSSL_Cleanup();<br />&nbsp; &nbsp; NetDisconnect( &amp;net.fd );<br />&nbsp; &nbsp; return FAILURE;<br />}</p><p>int pahoclient_run(void)<br />{<br />&nbsp; &nbsp; int rc = MQTTSUCCESS;</p><p>&nbsp; &nbsp; if(MQTTIsConnected(&amp;client)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; rc = MQTTYield(&amp;client, 100);<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; return rc;<br />}</p><p>int NetRead( int* fd, char *Buf, int len, int timeout_ms)<br />{<br />&nbsp; &nbsp; int rc;<br />&nbsp; &nbsp; struct timeval tv;<br />&nbsp; &nbsp; int so_error = 0;<br />&nbsp; &nbsp; int index;</p><p>&nbsp; &nbsp; /* check before entering */<br />&nbsp; &nbsp; if(*fd &lt; 0 || Buf == NULL || len &lt;= 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; return -1;</p><p>&nbsp; &nbsp; /* Set timeouts for socket */<br />&nbsp; &nbsp; setup_timeout(&amp;tv, timeout_ms);<br />&nbsp; &nbsp; rc = setsockopt( *fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&amp;tv, sizeof(tv));<br />&nbsp; &nbsp; LWIP_ASSERT(&quot;rcvtimeo sockopt&quot;, rc == 0);</p><p>&nbsp; &nbsp; index = 0;</p><p>&nbsp; &nbsp; /* Try reading amount of data */<br />&nbsp; &nbsp; while( index &lt; len ) {<br />&nbsp; &nbsp; &nbsp; &nbsp; rc = read( *fd, &amp;Buf[index], len - index );<br />&nbsp; &nbsp; &nbsp; &nbsp; if(rc &lt; 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Get error */<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; socklen_t len = sizeof(so_error);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getsockopt(*fd, SOL_SOCKET, SO_ERROR, &amp;so_error, &amp;len);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (so_error == 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LWIP_ASSERT(&quot;socketerror&quot;, so_error == 0);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rc = so_error; /* return error */<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = len;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index += rc;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; };</p><p>&nbsp; &nbsp; LWIP_ASSERT(&quot;index == len&quot;, index == (int)len);</p><p>&nbsp; &nbsp; return rc;<br />}</p><p>static int TlsSocketReceive(WOLFSSL* ssl, char *buf, int sz, void *ptr)<br />{<br />&nbsp; &nbsp; int rc;<br />&nbsp; &nbsp; Net *net = (Net*)ptr;<br />&nbsp; &nbsp; (void)ssl; /* Not used */<br />&nbsp; &nbsp; rc = net-&gt;read(&amp;net-&gt;fd, (char*)buf, sz, 100);<br />&nbsp; &nbsp; if (rc == 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; rc = WOLFSSL_CBIO_ERR_WANT_READ; &lt;--- this is the place causing the error<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else if (rc &lt; 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; rc = WOLFSSL_CBIO_ERR_GENERAL;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; return rc;<br />}</p><p>What is the correct way of using wolfssl together with lwip library and timeouts?<br />Thanks in advance</p>]]></description>
			<author><![CDATA[null@example.com (MO380)]]></author>
			<pubDate>Fri, 18 Oct 2024 20:54:48 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post7954.html#p7954</guid>
		</item>
	</channel>
</rss>
