My client can not receive data in blocking mode

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

My client can not receive data in blocking mode

llf@e-code.net
Hello
 
I'm using openssl as client in blocking mode , i have a problem .
Sometimes my program can't  receive data , and acctually server has been sent the data to me.
I can only  receive the data by sending another request . Then the data i expected arrived with a new data sent by server .

------------------------------------------------------------------------------
bool can_read()
{
      if(SSL_pending(m_ssl))
            return true;
struct timeval tv = {0 , 100};
       FD_ZERO(&m_rfds);
       FD_SET(m_socket.fd(), &m_rfds);
int ret = select( m_socket.fd()+1, &m_rfds , NULL, NULL, &tv);
return ret > 0 ;
}
 
//this is the main process
int try_receive(char * buf , int len )
{
if( !can_read())
return -1;
 
return SSL_read(m_ssl, buf, len);
}
-------------------------------------------------------------------------------
 Above is my code ,  my program get `false` from `can_read` although the server has sent response data
 I really appreciate your help.

Reply | Threaded
Open this post in threaded view
|

Re: My client can not receive data in blocking mode

John Unsworth-3
You do not say what OS you are running on. Solaris 11 has a known problem with not reporting queued data. This was fixed by SRU-28.

Regards,
John Unsworth 

From: openssl-users <[hidden email]> on behalf of 路连峰 <[hidden email]>
Sent: Monday, September 23, 2019 4:55 am
To: openssl-users
Subject: My client can not receive data in blocking mode

Hello
 
I'm using openssl as client in blocking mode , i have a problem .
Sometimes my program can't  receive data , and acctually server has been sent the data to me.
I can only  receive the data by sending another request . Then the data i expected arrived with a new data sent by server .

------------------------------------------------------------------------------
bool can_read()
{
      if(SSL_pending(m_ssl))
            return true;
struct timeval tv = {0 , 100};
       FD_ZERO(&m_rfds);
       FD_SET(m_socket.fd(), &m_rfds);
int ret = select( m_socket.fd()+1, &m_rfds , NULL, NULL, &tv);
return ret > 0 ;
}
 
//this is the main process
int try_receive(char * buf , int len )
{
if( !can_read())
return -1;
 
return SSL_read(m_ssl, buf, len);
}
-------------------------------------------------------------------------------
 Above is my code ,  my program get `false` from `can_read` although the server has sent response data
 I really appreciate your help.

Reply | Threaded
Open this post in threaded view
|

My client can not receive data in blocking mode

llf@e-code.net
Thank you very much for your reply  .
My server running on centos 7.5 . And client running on windows 10 .
The data seems be cached on the server and not be sent out.  Dose centos  have the same problem?
I'm not sure what the problem is .
I would really appreciate if you have any Suggestions.
 
Best Regards
 
发件人: [hidden email]
发送时间: 2019-09-27 21:48
主题: Re: My client can not receive data in blocking mode
You do not say what OS you are running on. Solaris 11 has a known problem with not reporting queued data. This was fixed by SRU-28.

Regards,
John Unsworth 

From: openssl-users <[hidden email]> on behalf of 路连峰 <[hidden email]>
Sent: Monday, September 23, 2019 4:55 am
To: openssl-users
Subject: My client can not receive data in blocking mode

Hello
 
I'm using openssl as client in blocking mode , i have a problem .
Sometimes my program can't  receive data , and acctually server has been sent the data to me.
I can only  receive the data by sending another request . Then the data i expected arrived with a new data sent by server .

------------------------------------------------------------------------------
bool can_read()
{
      if(SSL_pending(m_ssl))
            return true;
struct timeval tv = {0 , 100};
       FD_ZERO(&m_rfds);
       FD_SET(m_socket.fd(), &m_rfds);
int ret = select( m_socket.fd()+1, &m_rfds , NULL, NULL, &tv);
return ret > 0 ;
}
 
//this is the main process
int try_receive(char * buf , int len )
{
if( !can_read())
return -1;
 
return SSL_read(m_ssl, buf, len);
}
-------------------------------------------------------------------------------
 Above is my code ,  my program get `false` from `can_read` although the server has sent response data
 I really appreciate your help.

Reply | Threaded
Open this post in threaded view
|

RE: My client can not receive data in blocking mode

Michael Wojcik
From: openssl-users [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Friday, September 27, 2019 11:42

> The data seems be cached on the server and not be sent out.

Is it? Have you run a network trace? Have you tried waiting longer than 100ms?

If your server is sending a segment shorter than the MSS, you may be seeing Nagle / Delayed ACK interaction. If that's holding up the end of a TLS record, then select will indicate the socket is readable but a subsequent SSL_read will block until the remainder of the record has been received.

A network trace, even without decryption, will give you some idea of when data is being sent, and how much.

--
Michael Wojcik
Distinguished Engineer, Micro Focus